Created
July 2, 2018 09:48
-
-
Save studio-fars-company/2cf4e67367bb79c086432652821a9c1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 指定のメールアドレスのアクティベーションコードを再送する | |
*/ | |
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