PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, April 19, 2022

[FIXED] how to change redirect after auth Email verification in laravel 8?

 April 19, 2022     email-verification, laravel, laravel-8, laravel-authentication, model-view-controller     No comments   

Issue

I have 2 condition after successful registration with email verification.

  1. If the new user is select plan from home page, redirects to registration page submits the form. then will get Email verfication link, and after email verified I want to redirect directly to checkout. Plan id will be saving session , so I can get all the details of plan.
  2. If the new user is not select plan from home page, then he can sign up and redirects to dashboard

But in laravel after email verfication always redirects to home page. But I dont want to redirect to home page again.

How can be this done? Wher can do the coding part?

Verification Controller


 use VerifiesEmails;

    /**
     * Where to redirect users after verification.
     *
     * @var string
     */
    protected $redirectTo = RouteServiceProvider::HOME;

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
        $this->middleware('signed')->only('verify');
        $this->middleware('throttle:6,1')->only('verify', 'resend');
    }
    
    protected function verified(Request $request)
    {
        $request->session()->flash('alert','Your Email is verfied');
    }


Routes

  public function emailVerification()
    {
        return function () {
            $this->get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
            $this->get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify');
            $this->post('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');
        };
    }

Solution

Add a method called redirectTo(). It will be called if it exists.

public function redirectTo()
{
   // put your routing logic here
}

The function should return a string of the url to go to.



Answered By - Snapey
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing