public function reactiveAction() { $username = $this->request->get('username'); if ($this->request->isAjax()) { if (!$username) { return $this->showErrorMessageAsJson(400, 'ERR_USER_REACTIVE_NO_USERNAME_INPUT'); } $user = new Models\Register(); try { $user->sendVerificationEmail($username); return $this->showResponseAsJson('SUCCESS_USER_ACTIVE_MAIL_SENT'); } catch (\Exception $e) { return $this->showExceptionAsJson($e, $user->getMessages()); } } else { if (!$username) { return $this->redirectHandler($this->getDI()->getConfig()->user->resetFailedRedirectUri); } $user = new Models\Register(); try { $user->sendVerificationEmail($username); $this->flashSession->success('SUCCESS_USER_ACTIVE_MAIL_SENT'); return $this->redirectHandler($this->getDI()->getConfig()->user->resetSuccessRedirectUri); } catch (\Exception $e) { $this->showException($e, $user->getMessages()); return $this->redirectHandler($this->getDI()->getConfig()->user->resetFailedRedirectUri); } } }
public function sendResetCaptchaAction() { $mobile = $this->request->getPost('mobile'); $registerModel = new Models\Register(); $registerModel->mobileCaptcha($mobile, $type = 1); $data = array('mobile' => $mobile, 'timestamp' => time()); return $this->showResponseAsJson($data); }
public function verifyAction() { $code = $this->dispatcher->getParam('code'); $username = $this->dispatcher->getParam('username'); $user = new Models\Register(); try { $user->verifyNewUser($username, $code); } catch (\Exception $e) { $this->showException($e, $user->getMessages()); return $this->redirectHandler($this->getDI()->getConfig()->user->activeFailedRedirectUri, 'error'); } $this->flashSession->success('SUCCESS_USER_ACTIVED'); return $this->redirectHandler($this->getDI()->getConfig()->user->activeSuccessRedirectUri); }
public function indexAction() { if (!$this->request->isPost()) { return; } if ($this->request->isAjax()) { $form = new Forms\RegisterForm(); if ($form->isValid($this->request->getPost()) === false) { return $this->showInvalidMessagesAsJson($form); } $user = new Models\Register(); $user->assign(array('username' => $this->request->getPost('username'), 'email' => $this->request->getPost('email'), 'password' => $this->request->getPost('password'))); $transaction = $this->getDI()->getTransactions()->get(); try { $transaction->begin(); $registerUser = $user->register(); $transaction->commit(); return $this->showResponseAsJson($registerUser); } catch (\Exception $e) { $transaction->rollback(); return $this->showExceptionAsJson($e, $user->getMessages()); } } else { $form = new Forms\RegisterForm(); if ($form->isValid($this->request->getPost()) === false) { $this->showInvalidMessages($form); return $this->redirectHandler($this->getDI()->getConfig()->user->registerFailedRedirectUri, 'error'); } $user = new Models\Register(); $user->assign(array('username' => $this->request->getPost('username'), 'email' => $this->request->getPost('email'), 'password' => $this->request->getPost('password'))); try { $user->register(); } catch (\Exception $e) { $this->showException($e, $user->getMessages()); return $this->redirectHandler($this->getDI()->getConfig()->user->registerFailedRedirectUri, 'error'); } $this->flashSession->success('SUCCESS_USER_REGISTERED_ACTIVE_MAIL_SENT'); return $this->redirectHandler($this->getDI()->getConfig()->user->registerSuccessRedirectUri); } }
public function register() { $accessToken = OAuthManager::getAccessToken(); if (!$accessToken) { throw new Exception\ResourceConflictException('ERR_OAUTH_NO_ACCESS_TOKEN'); } $register = new UserRegister(); $register->username = $this->username; $register->email = $this->email; $register->status = 'active'; $register->accountType = 'basic'; $register->emailStatus = 'inactive'; $register->providerType = $accessToken['adapterKey'] . '_' . $accessToken['version']; $user = $register->register(true); $accessTokenEntity = new AccessTokens(); $accessTokenEntity->assign($accessToken); $accessTokenEntity->tokenStatus = 'active'; $accessTokenEntity->userId = $user->id; if (!$accessTokenEntity->save()) { throw new Exception\RuntimeException('ERR_OAUTH_TOKEN_CREATE_FAILED'); } return $user; }
public function mobileCaptchaCheckAction() { $mobile = $this->request->getPost('mobile'); $captcha = $this->request->getPost('captcha'); $registerModel = new Models\Register(); $result = $registerModel->mobileCaptchaCheck($mobile, $captcha); $data = array('mobile' => $mobile, 'result' => $result); return $this->showResponseAsJson($data); }