F
F
feniksdv2021-04-05 17:45:07
Laravel
feniksdv, 2021-04-05 17:45:07

How to change authentication in Laravel?

Hello, and who can tell me about Laravel, here is the standard user authorization code.

if (Auth::attempt(['email' => $email_, 'password' => $info['id']])) {
          return redirect()->route('dashboard');
}

I want to authorize not by the password column, but by the qwe column.
if (Auth::attempt(['email' => $email_, 'qwe' => $info['id']])) {
          return redirect()->route('dashboard');
}

There is a retrieveByCredentials method in the lark , it takes these password parameters without fail, and here's how to override it in the qwe controller, or maybe everything is done differently, in short, who can tell me how to be ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
feniksdv, 2021-04-05
@feniksdv

Decision for posterity

if(isset($info['default_email']) == isset($email_)) //нашли пользователя
{
//echo $email_; //емаил [email protected]
//echo $password; // пароль зашифрован $2y$10$RBCVQGnQZi...caMJ7s3HrJAba

$user = User::query()
             ->where('email', $email_)
              ->where('yandex_key', $password)
              ->first();

    if($user) { //аутентификацию пользователя
       Auth::login($user);
       return redirect()->route('dashboard');
    }
}

J
JhaoDa, 2021-04-05
@JhaoDa

0. This is not authorization, but authentication.
1. We read .
2. We create our own user provider, write the necessary logic in retrieveByCredentials.
3. We use.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question