lundi 15 avril 2019

Laravel 5.7 Email Verification Logging User Out

In my laravel application i am trying to use the verification functionality for newly registered users.

The current functionality is when a user registers they are shown a page prompting them to check their email. The user clicks the link in the email to verify their email they are then redirected to /account which as an Auth protected route. However when the user then tries to navigate to another Authed route they are redirected to the login page!

From some research people are saying this is expected that the user would have to login in again but this is a terrible user experience to me.

I did try to modify the verify method in the VerificationController like this:


public function verify(Request $request)
    {


        $userId = $request->route('id');
        $user = User::findOrFail($userId);


        Auth::login($user);

        if ($user->markEmailAsVerified()) {
            event(new Verified($user));
        }

        return redirect($this->redirectPath());
    }



No such luck!

Ideally i want the user to click the link in the email and they then remain logged in for their session.

Any help would be great!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire