예제 #1
0
 /**
  * Shows the forgot password form
  */
 public function forgotPasswordAction()
 {
     $form = new ForgotPasswordForm();
     if ($request->isPost()) {
         if ($form->isValid($request->getPost()) == false) {
             foreach ($form->getMessages() as $message) {
                 $this->flash->error($message);
             }
         } else {
             $user = Users::findFirstByEmail($request->getPost('email'));
             if (!$user) {
                 $this->flash->success('There is no account associated to this email');
             } else {
                 $resetPassword = new ResetPasswords();
                 $resetPassword->usersId = $user->id;
                 if ($resetPassword->save()) {
                     $this->flash->success('Success! Please check your messages for an email reset password');
                 } else {
                     foreach ($resetPassword->getMessages() as $message) {
                         $this->flash->error($message);
                     }
                 }
             }
         }
     }
     $this->view->form = $form;
 }
예제 #2
0
 /**
  * Deletes a User
  *
  * @param int $id
  */
 public function deleteAction($id)
 {
     $user = Users::findFirstById($id);
     if (!$user) {
         $this->flash->error("User was not found");
         return $this->dispatcher->forward(array('action' => 'index'));
     }
     if (!$user->delete()) {
         $this->flash->error($user->getMessages());
     } else {
         $this->flash->success("User was deleted");
     }
     return $this->dispatcher->forward(array('action' => 'index'));
 }
예제 #3
0
파일: Auth.php 프로젝트: kjmtrue/blog
 /**
  * Get the entity related to user in the active identity
  *
  * @return \Phalconvn\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 Exception('The user does not exist');
         }
         return $user;
     }
     return false;
 }