#Laravel 9 Auth problem

43 messages · Page 1 of 1 (latest)

round forum
#

I am trying to login in my application, but the auth keeps on failing. any help would be appreciated

spare gulch
#

Enter the correct credentials. Maybe.

round forum
#

i did ..

spare gulch
#

Is your database connected?

round forum
#
class LoginController extends Controller
{
    public function index(){
        return view('login');
    }

    public function logout(){
        Session::flush();
        Auth::logout();
        return redirect('login');
    }

    public function validate_login(Request $request){


        $credentials = $request->validate([
           'email' => 'required|exists:users,email',
           'password' => 'required'
        ]);
//        $credentials['password'] = bcrypt($credentials['password']);


        if (Auth::attempt($credentials)){
            dd("i am in");
        }else{
            dd("i am not in");
        }
        exit;

        throw ValidationException::withMessages([
            'email' => 'Your provided crednetials could not be verified.',
            'password' => 'Password didn`t match'
        ]);

    }
}
#

yup

spare gulch
#

😄 was building up a joke for the missing code. You've ruined it!

round forum
#

ahh mb

#

this is my login controller

#

do you also want to see my request controller?

spare gulch
#

You should not hash the password specified as the password value, since the framework will automatically hash the value before comparing it to the hashed password in the database.

round forum
#

yes is read that part later

#

but it is strange that i wont get inside the if statement

#

even though my credentials are correct

spare gulch
#

Oh, I didn't see that you've commented out that line

#

Well, then your validation is not passing.

#

Try to dump something before you validate, or remove it temporarily

round forum
#

in my database my password is not hashed

#

will that be a problem ?

spare gulch
#

Yes, of course

round forum
#

ah ok, does laravel uses md5 hash

spare gulch
#

I hope not

round forum
#

or doesn't it matteR?

spare gulch
#

You should read some docs man

grave atlas
#

It matters and NO it does not use md5.

#

Wtf did I type bcrypt for

spare gulch
#

Ur high

round forum
grave atlas
#

In your database: HASH IT
When doing Auth::attempt do NOT hash it

round forum
#

ok understandable

spare gulch
#

Storing plain passwords is baaaad

grave atlas
#

The example in the docs also addresses this

round forum
#

lovely

#

ur my hero's !

#

how can i solve my case?

grave atlas
#

we're the dynamic duo

grave atlas
spare gulch
#

I'm Batman and @grave atlas is my robin

round forum
#

lovely

#

love the laravel community

warped urchin
#

Can I be cat woman ?

#

You might want to also consider using jetstream depending on your app needs. Save you a lot of the stress right now.