joenpc npcsolution
joenpc npcsolution

Reputation: 767

How to chage redirect route after email verification in Laravel7?

I have email verification url as below created by laravel email verify route.

http://localhost/myproject/public/email/verify

After email verified, then I call this url again. It redirect to home route as below url.

http://localhost/myproject/public/home

But I would like to redirect to specific route instead. Any advice or guidance to override somewhere on this would be greatly appreciated, Thanks.

Upvotes: 0

Views: 399

Answers (2)

joenpc npcsolution
joenpc npcsolution

Reputation: 767

I have solution by override show method and also user()->hasVerifiedEmail();

public function show(Request $request)
    {
        if ($request->user()->hasVerifiedEmail() == 1){
        ....

if verified then redirect to target route else redirect to view('auth.verify');

Upvotes: 0

Stefano Amorelli
Stefano Amorelli

Reputation: 4854

We can modify the redirect URL after the email has been verified by the end-user, by setting the redirectTo property in the VerificationController, as stated in the official documentation:

After an email address is verified, the user will automatically be redirected to /home. You can customize the post verification redirect location by defining a redirectTo method or property on the VerificationController.

protected $redirectTo = '/home';

Upvotes: 0

Related Questions