vendredi 21 octobre 2016

Do we really need to implement Auth::attempt() in laravel in order to authenticate a user?

Hi this question is related to PHP Laravel Framework. Do we really need to implement Auth::attempt() in laravel in order to authenticate a user? If we manually code it like below what will be the disadvantages? Are there any outstanding benefits of using Auth::attempt()?

eg code for manually authentication:

  $member = Member::where('email', $username_email)
        ->orwhere('username', $username_email)->first();

    if ($member) {
        if (Hash::check($password, $member->getPassword())) {
         //login success code
        }else{
         //login fail code
        }
    }

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire