1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Auth::check() and Auth::attempt() return false in server for a certain table

Discussão em 'Outras Linguagens' iniciado por Konayuki, Outubro 16, 2024 às 08:42.

  1. Konayuki

    Konayuki Guest

    I tried to make login using MD5 (yes I know it's not recommended, but for a certain reason, I have to try it), and here's how I implemented it in LoginController, while user's data was taken from table users:

    $user = User::where([
    'email' => $request->username,
    'password' => md5($request->password)
    ])->first();

    if ($user) {
    Auth::guard('someguard')->login($user, true);
    return redirect()->route('some-route');
    }


    Then I have a middleware, it was simple:

    if (!Auth::guard('someguard')->check())
    return redirect()->to('some-route-a');


    Locally (in Windows), everything ran fine.

    But when the code was up in server (Linux), for MD5 login, check() in middleware would return false. Yet when I tried to print the check() result in LoginController, it still returned true.

    Then, out of curiosity, I tried to change the password in the in the table users in database to hashed bcrypt, and login using this:

    if (Auth::guard('someguard')->attempt(['email' => $request->username, 'password' => $request->password]))


    Fine in local, but in server attempt() return false.

    Now, there's another database for another website with their own users table where password stored using bcrypt. What confusing me is when I used this table, attempt() and check() both ran fine whether in local or in server.

    I used PHP 8.3.12 and 8.3.8, and the results for all are the same.

    Any idea why, in server, none worked for the first table?

    Continue reading...

Compartilhe esta Página