添加 被 ban 逻辑
This commit is contained in:
parent
14fc6c39c1
commit
2c87d4a701
@ -37,10 +37,16 @@ public function __construct(Auth $auth)
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if ($this->auth->guard($guard)->guest()) {
|
||||
$auth = $this->auth->guard($guard);
|
||||
if ($auth->guest()) {
|
||||
return $this->unauthorized('Unauthorized.');
|
||||
}
|
||||
|
||||
$user = $this->auth->guard($guard)->user();
|
||||
if ($user->banned_at) {
|
||||
return $this->forbidden('您已被封禁,原因是: ' . $user->banned_reason);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'balance' => 'float',
|
||||
'banned_at' => 'datetime',
|
||||
];
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user