Tauras
Tauras

Reputation: 3904

After email verification, redirect user to specified path which is based on request

protected function verificationUrl($notifiable) {
    return URL::temporarySignedRoute(
        'verification.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]
    );
}

this function creates URL with all data based on $notifiable json data. Which is passed to email.

$this->verificationUrl($notifiable)

I have zero success to make this URL and actual email verification to work with additional redirectTo parameter. Whenever i am trying to add this parameter, all verification proccess brakes. It just feels like is not allowed to have something additional.

I can store a cookie, which will be in use after verification, however, is there a technically more correct way todo this using VerificationController?

protected $redirectTo = '/';

public function __construct() {
    $this->middleware('auth');
    $this->middleware('signed')->only('verify');
    $this->middleware('throttle:6,1')->only('verify', 'resend');
}

tried:

protected function verificationUrl($notifiable) {
    return URL::temporarySignedRoute(
        'verification.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]
    ).'&redirectTo=https://root.loc/whatever'; 
}

i even tried to parse generated URL (without additional parameter), and insert in other position. However, with still no success.

Upvotes: 1

Views: 482

Answers (1)

Travis Britz
Travis Britz

Reputation: 5552

You're adding the parameter in the wrong place. It should be in the array for the third argument passed to URL::temporarySignedRoute():

protected function verificationUrl($notifiable)
{
    return URL::temporarySignedRoute(
        'verification.verify',
        Carbon::now()->addMinutes(60), [
            'id' => $notifiable->getKey(),
            'redirect_to' => route('foo')
        ]
    );
}

Upvotes: 1

Related Questions