mardi 11 février 2020

How to login using sql password() function in laravel?

I want to login using the sql password() function in laravel. This is because the master database of employee table contains password in the format insert into tbl_name(' ') values (' ', password('abc')); So I need to use this master table for login so can anyone suggest me as to how can this be possible?

    public function login(Request $request) {
        // dd($request->all());        
        if(Auth::attempt([
            'tgi' => $request->tgi,
            'password' => $request->password
        ]))
        {
            // $user = User::where('tgi', $request->tgi)->first();
            $user = MasterLogin::where('tgi', $request->tgi)->first();
            if($user->is_admin() == '1') {
                return redirect()->route('dashboard');
            }
            elseif($user->is_admin() == '0'){
                return redirect()->route('home');
            }
            elseif($user->is_admin() == '3'){
                return redirect()->route('manager');
            }
        }
        return redirect()->back();
    } 
public function validateCredentials(UserContract $user, array $credentials)
    {
        $plain = $credentials['password'];

        return $this->hasher->check($plain, $user->getAuthPassword());
    }

In validateCredentials i would like to know how can I pass the password here.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2uvtAa6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire