Quantcast
Channel: Login only if user is active using Laravel - Stack Overflow
Browsing index pages (25 articles)

Login only if user is active using Laravel

I'm currently working on my Laravel app and to prevent spam I decided that only active users are able to login.I'm currently using Laravel's login system just like in Laravel's official website...

View Article


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

Laravel 5.4 / 5.5Override the default login() function by placing this function in your LoginController:public function login(\Illuminate\Http\Request $request) { $this->validateLogin($request); //...

View Article


Answer by Can Celik for Login only if user is active using Laravel

You don't have to override the whole function. You can just change the Validator in AuthController to achieve that adding "exists:table,column" validation.Let's assume that you have a users table with...

View Article

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

in AuthController override method getCredentials like this:protected function getCredentials(Request $request) { $request['active'] = TRUE; return $request->only($this->loginUsername(),...

View Article

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

Paste the following method to your LoginController.protected function validateLogin(Request $request){ $this->validate($request, [ $this->username() => 'exists:users,' . $this->username() ....

View Article


Answer by Raja Amer Khan for Login only if user is active using Laravel

In Laravel 5.4 open Auth/LoginController.phpand add this function:/** * Get the needed authorization credentials from the request. * * @param \Illuminate\Http\Request $request * @return array */...

View Article

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

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...

View Article

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

I check user is actived by overwrite sendLoginResponse function in LoginControllerprotected function sendLoginResponse(Request $request){ if($this->guard()->user()->active == 0){...

View Article


Answer by Piotr Jankiewicz for Login only if user is active using Laravel

If someone uses ajax request on login and wants to have custom message, here is how I achieved this in login controller:login() function // This section is the only change if...

View Article


Answer by The Billionaire Guy for Login only if user is active using Laravel

Thanks @Can_Celikthis was how I was able to solve my issue becos i was using json response with jquery./** * Validate the user login request. * * @param \Illuminate\Http\Request $request * @return void...

View Article

Answer by Ryan Tirrell for Login only if user is active using Laravel

I'm new to Laravel, and this is aimed at newcomers too. Long-timers feel free to tell me why this is bad practice, as I genuinely don't know any better yet. As at 24th August 2019 - using Laravel 5.8 -...

View Article

Answer by Guido Donnari for Login only if user is active using Laravel

You can use Eloquent scopes: https://laravel.com/docs/5.5/eloquent#query-scopeslike this:class User extends Authenticatable {.../** * The "booting" method of the model. * * @return void */ protected...

View Article

Answer by thiago tanaka for Login only if user is active using Laravel

Laravel 5.8 tested. Put this code in your LoginController.php and be happy.public function login(Request $request){ $user = User::where('username',$request->username)->first(); if( $user...

View Article


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

Most logical, and clean, is to handle this within the validateLogin method.LoginController.php(Laravel 6.x)/** * Validate the user login request. * * @param \Illuminate\Http\Request $request * @return...

View Article

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

Laravel 6.6 tested. Overwrite validateLogin in your LoginController.phpuse Illuminate\Http\Request;use App\User;use Illuminate\Validation\ValidationException;....../** * Validate the user login...

View Article


Answer by Duy Nguyen for Login only if user is active using Laravel

In case, you want to keep everything as simple, you can use Laravel built-in feature. It is email verification. I do not guarantee this way would resolve your problem. It is reference in case you...

View Article

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

On laravel 7, you only need to put this method on LoginController:/** * Custom credentials to validate the status of user. */public function credentials(Request $request){ return ['email' =>...

View Article


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

Probably not the best but, I think I found a cleaner way to override the login method. I tried this on Laravel 7in Auth\LoginController.php, put these classesuse Illuminate\Support\Facades\Auth;use...

View Article

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

Works on Laravel 7I know this has already been answered many times but here was my approach and it isn't much different from some of the others but I wanted to provide a little more detailed...

View Article

Answer by Rashi Goyal for Login only if user is active using Laravel

protected function sendLoginResponse(Request $request) { $request->session()->regenerate(); $this->clearLoginAttempts($request); if ($response = $this->authenticated($request,...

View Article
Browsing index pages (25 articles)


Latest Images