회원 등록대기 이메일 저장소를 반환한다.
public pendingEmails ( ) : Xpressengine\User\Repositories\PendingEmailRepositoryInterface | ||
Результат | Xpressengine\User\Repositories\PendingEmailRepositoryInterface |
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' => '인증되었습니다. 로그인하시기 바랍니다.']); }
/** * confirm email * * @param Request $request * * @return \Xpressengine\Presenter\RendererInterface */ public function postConfirmMail(Request $request) { $pendingEmail = $this->handler->pendingEmails()->find($request->get('id')); if ($pendingEmail === null) { $e = new InvalidArgumentHttpException(); $e->setMessage('존재하지 않거나 이미 승인된 이메일입니다.'); throw $e; } $user = $pendingEmail->user; $address = $pendingEmail->address; XeDB::beginTransaction(); try { // create pending email $email = $this->handler->emails()->create($user, compact('address')); // remove pending email $this->handler->pendingEmails()->delete($pendingEmail); } catch (Exception $e) { XeDB::rollBack(); throw $e; } XeDB::commit(); return XePresenter::makeApi(['mail' => $email]); }