Support the ongoing development of Laravel.io →
Authentication Database Eloquent
Last updated 2 years ago.
0

simply write your own logic on the AuthController.

0

astroanu said:

simply write your own logic on the AuthController.

Hi

Thank you for your reply. AuthController looks like it only has a construct method. I cant see clearly how to go about this. Any examples would be greatly appreciated.

0

The controller has a trait AuthenticatesAndRegistersUsers which uses trait AuthenticatesUsers. The AuthenticatesUsers trait has a postLogin function. You need to define your own postLogin function to override what's on the trait. Something like this would do. Assuming the passwords are stored with md5

    public function postLogin(UserLoginRequest $request)
    {
        if (($user = User::where(['email' => $request->get('email'), 'password' => md5($request->get('password'))])->first()) instanceOf User) {
             Auth::login($user);

             // authenticated, redirect now
        }

        return $this->printJson(false, [], 'These credentials do not match our records.');
    }
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

sonesay sonesay Joined 1 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.