Exemple #1
0
 /**
  * Deletes a User
  *
  * @param int $id
  */
 public function deleteAction($id)
 {
     $user = Users::findFirstById($id);
     if (!$user) {
         $this->flash->error($this->translate->gettext('User was not found'));
         return $this->dispatcher->forward(['action' => 'index']);
     }
     if (!$user->delete()) {
         $this->flash->error($user->getMessages());
     } else {
         $this->flash->success($this->translate->gettext('User was deleted'));
     }
     return $this->dispatcher->forward(['action' => 'index']);
 }
 /**
  * Shows the forgot password form
  */
 public function forgotPasswordAction()
 {
     $form = new ForgotPasswordForm();
     $form->setDI($this->getDI());
     if ($this->request->isPost()) {
         if ($form->isValid($this->request->getPost()) !== false) {
             $user = Users::findFirstByEmail($this->request->getPost('email'));
             if (!$user) {
                 $this->flash->success($this->translate->gettext('There is no account associated with this email.'));
             } else {
                 $resetPassword = new ResetPasswords();
                 $resetPassword->usersId = $user->id;
                 if ($resetPassword->save()) {
                     $this->flash->success($this->translate->gettext('An email has been sent!'));
                     $this->flash->success($this->translate->gettext('Please check your inbox for a reset password message.'));
                     return $this->dispatcher->forward(['controller' => 'index', 'action' => 'notification']);
                 } else {
                     foreach ($resetPassword->getMessages() as $message) {
                         $this->flash->error($message);
                     }
                 }
             }
         }
     }
     $this->view->form = $form;
 }
Exemple #3
0
 /**
  * Get the entity related to user in the active identity
  *
  * @return \Webird\Models\Users
  */
 public function getUser()
 {
     $identity = $this->session->get('auth-identity');
     if (isset($identity['id'])) {
         $user = Users::findFirstById($identity['id']);
         if ($user == false) {
             throw new AuthException('The user does not exist');
         }
         return $user;
     }
     return false;
 }
Exemple #4
0
 /**
  *
  */
 private function getUserByUniqueRef($userRef)
 {
     if (ctype_digit($userRef)) {
         $user = Users::findFirstById($userRef);
     } else {
         if (($email = filter_var($userRef, FILTER_VALIDATE_EMAIL)) !== false) {
             $user = Users::findFirstByEmail($email);
         } else {
             throw new ArgumentValidationException('The user must be specified as an email or primary key.', 1);
         }
     }
     return $user;
 }