public function getConfirm(Request $request)
{
// validation
$this->validate($request, ['email' => 'required|email']);
$address = $request->get('email');
$code = $request->get('code');
// code가 없을 경우 인증 페이지 출력
if ($code === null) {
return \XePresenter::make('register_confirm');
}
$email = $this->handler->pendingEmails()->findByAddress($address);
if ($email === null) {
// todo: change exception to http exception
throw new PendingEmailNotExistsException();
}
XeDB::beginTransaction();
try {
$this->emailBroker->confirmEmail($email, $code);
} catch (Exception $e) {
XeDB::rollback();
throw $e;
}
XeDB::commit();
return redirect('/')->with('alert', ['type' => 'success', 'message' => '인증되었습니다. 로그인하시기 바랍니다.']);
}