Skip to content

Instantly share code, notes, and snippets.

@studio-fars-company
Created July 2, 2018 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save studio-fars-company/2cf4e67367bb79c086432652821a9c1d to your computer and use it in GitHub Desktop.
Save studio-fars-company/2cf4e67367bb79c086432652821a9c1d to your computer and use it in GitHub Desktop.
/**
* 指定のメールアドレスのアクティベーションコードを再送する
*/
protected function resendActivationCode(Request $request) {
// 古いアクティベーションコードを削除
Activation::removeExpired();
// ユーザーを確認
$user = Sentinel::findByCredentials(['email' => base64_decode($request->email)]);
if (is_null($user)) {
return redirect('login')->with(['myerror' => trans('sentinel.invalid_activation_params')]);
}
// すでにアクティベート済みの時は、何もせずにログインへ
if (Activation::completed($user)) {
return redirect('login')->with(['info' => trans('sentinel.activation_done')]);
}
// アクティベーションの状況を確認
$exists = Activation::exists($user);
if (!$exists) {
// 存在しない場合は、再生成して、そのコードを送信する
$activation = Activation::create($user);
}
else {
// 現在のコードを
$activation = $exists;
}
// メールで送信する
$usermodel = User::where('email', $user->email)->get()[0];
$usermodel->notify(new RegisterNotify($activation->code));
// メールを確認して、承認してからログインすることを表示するページへ
return redirect('login')->with('info', trans('sentinel.after_register'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment