First time with Laravel and following Laravel 5.4 from scratch: user can't sign in.

Published 1 year ago by mvww11

Hello, guys!

I started with Laravel this week. I'm following the Laravel from Scratch 5.4 series.

I was getting everything right until I tryed to sign any user that I created in. The system responds as the user/pass was incorrect (It returns the proper error message). But I'm sure that the user/pass is correct because I can see it on phpmyadmin (the password is in plain text, not hashed.).

Form:

<form method="POST" action="/login">

    {{ csrf_field() }}

    
    <div class="form-group">

    <label for="email">Email:</label>
    <input type="email" class="form-control" id="email" name="email">

    </div>

    <div class="form-group">

    <label for="password">Password:</label>
    <input type="password" class="form-control" id="password" name="password">


    </div>

     <div class="form-group">
    <button type="submit" class="btn btn-primary">Sign In</button>
  </div>

Route:

Route::post('/login', '[email protected]');

SessionsController:

    public function store()
    {
        if (! auth()->attempt(request(['email', 'password']))) {
            return back()->withErrors(['message' => 'Please check again']);
        }
        return redirect()->home();
    }

I would apreciate any help. Thanks!

Best Answer (As Selected By mvww11)
Ruffles

(the password is in plain text, not hashed.).

There's the problem. Laravel's login function (whichever you use) is comparing hashed passwords and that's why you can't login.

Hash the password with bcrypt($password) and it will probably work.

Ruffles
Ruffles
1 year ago (294,840 XP)

(the password is in plain text, not hashed.).

There's the problem. Laravel's login function (whichever you use) is comparing hashed passwords and that's why you can't login.

Hash the password with bcrypt($password) and it will probably work.

mvww11
mvww11
1 year ago (4,760 XP)

Ruffles, it did the trick. Thanks!

Please sign in or create an account to participate in this conversation.