Quantcast
Channel: Login only if user is active using Laravel - Stack Overflow
Viewing all articles
Browse latest Browse all 25

Answer by daprezjer for Login only if user is active using Laravel

$
0
0

In case anyone is came here looking for information on Laravel 5.4/5.5, and that allows for a custom message just for this scenario (not a combined message) here's the answer for that from https://laracasts.com/discuss/channels/laravel/user-account-status

Override the 'authenticated' method within your'app/Http/Controllers/Auth/LoginController.php` file:

/** * The user has been authenticated. * * @param  \Illuminate\Http\Request  $request * @param  mixed  $user * @return mixed */protected function authenticated(Request $request, $user){    if ($user->status_id == 2) { // or whatever status column name and value indicates a blocked user        $message = 'Some message about status';        // Log the user out.        $this->logout($request);        // Return them to the log in form.        return redirect()->back()            ->withInput($request->only($this->username(), 'remember'))            ->withErrors([                // This is where we are providing the error message.                $this->username() => $message,            ]);    }}

Viewing all articles
Browse latest Browse all 25

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>