Laravel Custom Authentication with Postgres

Asked

Viewed 33 times

0

I created a custom provider, called CustomUserProvider, extendi of EloquentUserProvider and brought the perfect fields.

However the login does not persist

public function validateCredentials(UserContract $user, array $credentials)
{
    $plain = $credentials['ususenha'];

    if ($plain == $this->hash($user->getAuthPassword())) {
        dd('Foi');
        return true;
    }

    return false;
}

In that code he falls in dd('Foi') but not logged and I made a test using MySQL and worked, using the MySQL works, but with the Postgres doesn’t work.

How to solve this problem?

  • 1

    Just one question, why did you create a Provider that already exists? What are the reasons that led you to do this, because you already have? I know these are boring questions, but I just don’t understand why replicate an existing code!

  • 1

    Well, I need to log in with a different encryption than the encryption available on the Laravel, it’s an encryption developed by the guys at the company, then, not to change the files inside vendor I created a Provider inheriting the characteristics of Eloquentuserprovider that is responsible for that part in the Modular, but I noticed that when I use Postgres it does not work! If I connect a mysql database works...

  • There are ways and means to do this, but, you say that you did not need to implement another code, because in Laravel I can check the password the way I want and with the instance of the user login class. Some examples: exemplo1, exemplo2 and this various types exemplo3.

  • continuing ... Then you do not need to make an implementation of this ... is a tip only to search the user for the information and with the instance give a command Auth::login($user) that works the same way

  • So, I’ve tried to make these forms, though Auth::login($user) only back null

  • You have to use the same mechanism and class that comes in Laravel

  • What do you mean? Below follows my code public function tentaLogar(Request $request)
 {
 $pessoa = User::where('usunome', $request->usunome)->first();
 
 if (sizeof($pessoa) > 0) {
 dd(Auth::login($pessoa));
 if ($this->hash($request->ususenha) === $pessoa->ususenha) {
 Auth::login($pessoa);

 return redirect($this->redirectTo);
 }

 }
 
 }

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.