优化会员限制
This commit is contained in:
parent
7ef966536d
commit
7e67fa3076
@ -5,6 +5,7 @@ namespace App\Exceptions;
|
|||||||
use App\Module\Base;
|
use App\Module\Base;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
@ -57,4 +58,18 @@ class Handler extends ExceptionHandler
|
|||||||
}
|
}
|
||||||
return parent::render($request, $e);
|
return parent::render($request, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重写report优雅记录laravel日志
|
||||||
|
* @param Throwable $e
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
public function report(Throwable $e)
|
||||||
|
{
|
||||||
|
if ($e instanceof ApiException) {
|
||||||
|
Log::error($e->getMessage(), ['exception' => ' at ' . $e->getFile() .':' . $e->getLine()]);
|
||||||
|
} else {
|
||||||
|
parent::report($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,6 +210,7 @@ class UsersController extends AbstractController
|
|||||||
{
|
{
|
||||||
$user = User::auth();
|
$user = User::auth();
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
|
$user->checkSystem(1);
|
||||||
//头像
|
//头像
|
||||||
if (Arr::exists($data, 'userimg')) {
|
if (Arr::exists($data, 'userimg')) {
|
||||||
$userimg = Request::input('userimg');
|
$userimg = Request::input('userimg');
|
||||||
@ -267,6 +268,7 @@ class UsersController extends AbstractController
|
|||||||
public function editpass()
|
public function editpass()
|
||||||
{
|
{
|
||||||
$user = User::auth();
|
$user = User::auth();
|
||||||
|
$user->checkSystem();
|
||||||
//
|
//
|
||||||
$oldpass = trim(Request::input('oldpass'));
|
$oldpass = trim(Request::input('oldpass'));
|
||||||
$newpass = trim(Request::input('newpass'));
|
$newpass = trim(Request::input('newpass'));
|
||||||
@ -279,15 +281,6 @@ class UsersController extends AbstractController
|
|||||||
return Base::retError('新旧密码一致');
|
return Base::retError('新旧密码一致');
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (env("PASSWORD_ADMIN") == 'disabled') {
|
|
||||||
if ($user->userid == 1) {
|
|
||||||
return Base::retError('当前环境禁止修改密码');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (env("PASSWORD_OWNER") == 'disabled') {
|
|
||||||
return Base::retError('当前环境禁止修改密码');
|
|
||||||
}
|
|
||||||
//
|
|
||||||
$verify = User::whereUserid($user->userid)->wherePassword(Base::md52($oldpass, User::token2encrypt()))->count();
|
$verify = User::whereUserid($user->userid)->wherePassword(Base::md52($oldpass, User::token2encrypt()))->count();
|
||||||
if (empty($verify)) {
|
if (empty($verify)) {
|
||||||
return Base::retError('请填写正确的旧密码');
|
return Base::retError('请填写正确的旧密码');
|
||||||
@ -462,6 +455,7 @@ class UsersController extends AbstractController
|
|||||||
if (empty($userInfo)) {
|
if (empty($userInfo)) {
|
||||||
return Base::retError('会员不存在或已被删除');
|
return Base::retError('会员不存在或已被删除');
|
||||||
}
|
}
|
||||||
|
$userInfo->checkSystem(1);
|
||||||
//
|
//
|
||||||
$upArray = [];
|
$upArray = [];
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
@ -145,6 +145,24 @@ class User extends AbstractModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查环境是否允许
|
||||||
|
* @param null $onlyUserid 仅指定会员
|
||||||
|
*/
|
||||||
|
public function checkSystem($onlyUserid = null)
|
||||||
|
{
|
||||||
|
if ($onlyUserid && $onlyUserid != $this->userid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (env("PASSWORD_ADMIN") == 'disabled') {
|
||||||
|
if ($this->userid == 1) {
|
||||||
|
throw new ApiException('当前环境禁止此操作');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (env("PASSWORD_OWNER") == 'disabled') {
|
||||||
|
throw new ApiException('当前环境禁止此操作');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** ***************************************************************************************** */
|
/** ***************************************************************************************** */
|
||||||
/** ***************************************************************************************** */
|
/** ***************************************************************************************** */
|
||||||
|
@ -78,6 +78,8 @@ export default {
|
|||||||
url: 'system/get/appinfo',
|
url: 'system/get/appinfo',
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.downList = data.list;
|
this.downList = data.list;
|
||||||
|
}).catch(() => {
|
||||||
|
this.downList = [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -124,6 +124,8 @@ export default {
|
|||||||
},
|
},
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.read_list = data;
|
this.read_list = data;
|
||||||
|
}).catch(() => {
|
||||||
|
this.read_list = [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -219,6 +219,8 @@ export default {
|
|||||||
url: 'system/get/appinfo',
|
url: 'system/get/appinfo',
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.downList = data.list;
|
this.downList = data.list;
|
||||||
|
}).catch(() => {
|
||||||
|
this.downList = [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user