lundi 10 février 2020

add in conditional to Laravel auth

In my users table I have role field which can be filled with any of admin, driver, petugas, rental. I want to let the user with role either admin or rental login, other than that the login system will deny the user.

I try to override the credentials() method in LoginController.php like below

protected function credentials(Request $request)
{
    $field = $this->field($request);

    return [
        $field => $request->get($this->username()),
        'password' => $request->get('password'),
        'role'=>['admin', 'jasa_angkutan', 'rental']
    ];
}

but it's not working.. I truely have no idea how to achieve the requirement.



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

Aucun commentaire:

Enregistrer un commentaire