簡體   English   中英

電子郵件驗證后,將用戶重定向到基於請求的指定路徑

[英]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()]
    );
}

此函數基於$notifiable json數據創建包含所有數據的URL。 傳遞到電子郵件。

$this->verificationUrl($notifiable)

使此URL和實際的電子郵件驗證與其他redirectTo參數一起使用時,我獲得零成功。 每當我嘗試添加此參數時,所有驗證過程都會停止。 只是感覺不允許有其他東西。

我可以存儲一個cookie,該cookie將在驗證后使用,但是在技術上,是否可以使用VerificationController來實現此目的?

protected $redirectTo = '/';

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

嘗試:

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

我什至試圖解析生成的URL(沒有附加參數),然后插入其他位置。 但是,仍然沒有成功。

您在錯誤的位置添加了參數。 它應該在傳遞給URL :: temporarySignedRoute()的第三個參數的數組中:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM