createEmail() public method

새로운 이메일을 생성한다
public createEmail ( Xpressengine\User\UserInterface $user, array $data, boolean $confirmed = true ) : Xpressengine\User\EmailInterface
$user Xpressengine\User\UserInterface user
$data array data
$confirmed boolean confirmed
return Xpressengine\User\EmailInterface
コード例 #1
0
 /**
  * add email
  *
  * @param Request $request
  *
  * @return \Xpressengine\Presenter\RendererInterface
  * @throws Exception
  */
 public function addMail(Request $request)
 {
     $input = $request->only('address');
     // validation
     $this->validate($request, ['address' => 'email|required'], [], ['address' => xe_trans('xe::email')]);
     // 이미 인증 요청중인 이메일이 있는지 확인한다.
     $useEmailConfirm = $this->handler->usingEmailConfirm();
     if ($useEmailConfirm) {
         if ($this->user->getPendingEmail() !== null) {
             $e = new PendingEmailAlreadyExistsException();
             throw new HttpException(400, $e->getMessage(), $e);
         }
     }
     // 이미 존재하는 이메일이 있는지 확인한다.
     if ($this->emails->findByAddress($input['address'])) {
         $e = new MailAlreadyExistsException();
         throw new HttpException(400, $e->getMessage(), $e);
     }
     //array_set($input, 'userId', $this->user->getId());
     XeDB::beginTransaction();
     try {
         $mail = $this->handler->createEmail($this->user, $input, !$useEmailConfirm);
         if ($useEmailConfirm) {
             /** @var EmailBroker $broker */
             $broker = app('xe.auth.email');
             $broker->sendEmailForConfirmation($mail);
         }
     } catch (\Exception $e) {
         XeDB::rollback();
         throw $e;
     }
     XeDB::commit();
     \Session::flash('alert', ['type' => 'success', 'message' => '추가되었습니다.']);
     return XePresenter::makeApi(['message' => '추가되었습니다']);
 }
コード例 #2
0
 /**
  * 주어진 이메일을 인증처리 한다.
  * 주어진 등록 대기 이메일의 인증코드가 주어진 인증코드와 동일하면
  * 해당 이메일을 해당회원의 실제 이메일로 등록하고, 본 등록대기 이메일은 삭제한다.
  *
  * @param EmailInterface $email 인증할 이메일
  * @param string         $code  인증코드
  *
  * @return bool 주어진 이메일의 인증처리가 성공하면 true를 반환한다.
  * @throws \Exception
  */
 public function confirmEmail(EmailInterface $email, $code)
 {
     if ($this->validateConfirmCode($email, $code) === false) {
         throw new InvalidConfirmationCodeException();
     }
     $info = ['address' => $email->getAddress()];
     // remove pending email & create confirmed email
     $this->handler->createEmail($email->user, $info, true);
     $this->handler->deleteEmail($email);
     return true;
 }