2016-03-21 93 views
4

用户注册后,我需要负担一个用户可以用来重新发送注册的链接。如何获取注册令牌?

由于我必须在链接中传递令牌,我将如何生成该令牌?

return redirect()->route('frontend.index')->withFlashSuccess(trans('exceptions.frontend.auth.confirmation.resend')); 

我怎么会传递令牌反式:

ex: http://dmain.com/account/confirm/resend/:token 

此外,在RegistersUsers

public function register(RegisterRequest $request) 
    { 
     if (config('access.users.confirm_email')) { 
      $user = $this->user->create($request->all()); 
      event(new UserRegistered($user)); 
      return redirect()->route('frontend.index')->withFlashSuccess(trans('exceptions.frontend.auth.confirmation.resend')); 
     } else { 
      auth()->login($this->user->create($request->all())); 
      event(new UserRegistered(access()->user())); 
      return redirect($this->redirectPath()); 
     } 
    } 

因此,如生成的链接?

'resend' => 'Your account is not confirmed. Please click the confirmation link in your e-mail, or <a href="' . route('account.confirm.resend', ':token') . '">click here</a> to resend the confirmation e-mail.', 
+0

您可以通过尝试'csrf_token()'函数 –

回答

1

我发现如何通过传递变量数组这样做:

return redirect()->route('frontend.index')->withFlashSuccess(trans('exceptions.frontend.auth.confirmation.resend', array('token' => $token))); 
0

可以保存_token您注册时的请求得到(令牌使用形式csrf_token()产生)。而且这个令牌可以嵌入到链接中以验证用户。