안녕하세요. ban_status가있는 로그인을 시도하는 사용자를 리디렉션하려고합니다. = 0Laravel 5.3 로그인 할 때 금지 된 사용자를 리디렉션
나는 이것을 수행하는 가장 좋은 방법이 무엇인지 궁금하여, 그냥 로그 아웃하고 금지 된 페이지로 리디렉션하려고 생각했지만 금지 된 사용자 만이 페이지에 액세스하거나 양식은 '금지되어 있습니다'등등. 내 코드는 현재 다음과 같습니다.
public function login (Request $ request) { $ this-> validateLogin ($ request);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if ($lockedOut = $this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
$credentials = $this->credentials($request);
if ($this->guard()->attempt($credentials, $request->has('remember'))) {
if ($this->guard()->user()->ban_status === 0) { // Check if the user is banned or not before allowing login
return $this->sendLoginResponse($request);
}
else {
$this->guard()->logout();
$request->session()->flush();
$request->session()->regenerate();
return redirect('/banned'); // If the user banned_status is set to 1, then they will be redirected to a banned page.
}
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if (! $lockedOut) {
$this->incrementLoginAttempts($request);
}
return $this->sendFailedLoginResponse($request);
}
당신은 아마 사용자가 금지되는 경우 확인하고 만약 그렇다면, 그것은 적절한 페이지로 리디렉션 미들웨어를 작성할 수 있습니다. – Skysplit