public function confirmMail(Request $request)
{
$code = $request->get('code');
$pendingMail = $this->user->getPendingEmail();
if ($pendingMail === null) {
throw new PendingEmailNotExistsException();
}
XeDB::beginTransaction();
try {
app('xe.auth.email')->confirmEmail($pendingMail, $code);
} catch (InvalidConfirmationCodeException $e) {
$e = new InvalidArgumentException();
$e->setMessage('잘못된 인증 코드입니다. 인증 코드를 확인하시고 다시 입력해주세요.');
throw $e;
} catch (\Exception $e) {
XeDB::rollback();
throw $e;
}
XeDB::commit();
\Session::flash('alert', ['type' => 'success', 'message' => '인증되었습니다.']);
return XePresenter::makeApi(['message' => '인증되었습니다.']);
}