简体   繁体   中英

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.

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')
        ]
    );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM