/** * 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; }
/** * 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')); }
/** * 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; }