/** * Delete a user. */ public function delete($userId) { $this->requireAdmin(); $user = $this->userStore->getById($userId); if (empty($user)) { throw new NotFoundException(Lang::get('user_n_not_found', $userId)); } $this->userService->deleteUser($user); header('Location: ' . PHPCI_URL . 'user'); die; }
/** * Delete a user. */ public function delete($userId) { $this->requireAdmin(); $user = $this->userStore->getById($userId); if (empty($user)) { throw new NotFoundException(Lang::get('user_n_not_found', $userId)); } $this->userService->deleteUser($user); $response = new b8\Http\Response\RedirectResponse(); $response->setHeader('Location', PHPCI_URL . 'user'); return $response; }
/** * Delete a user. */ public function delete($userId) { if (!$_SESSION['user']->getIsAdmin()) { throw new ForbiddenException('You do not have permission to do that.'); } $user = $this->userStore->getById($userId); if (empty($user)) { throw new NotFoundException('User with ID: ' . $userId . ' does not exist.'); } $this->userService->deleteUser($user); header('Location: ' . PHPCI_URL . 'user'); die; }
public function resetPassword($userId, $key) { $user = $this->userStore->getById($userId); $userKey = md5(date('Y-m-d') . $user->getHash()); if (empty($user) || $key != $userKey) { $this->view->error = 'Invalid password reset request.'; return $this->view->render(); } if ($this->request->getMethod() == 'POST') { $hash = password_hash($this->getParam('password'), PASSWORD_DEFAULT); $user->setHash($hash); $_SESSION['user'] = $this->userStore->save($user); $_SESSION['user_id'] = $user->getId(); header('Location: ' . PHPCI_URL); die; } $this->view->id = $userId; $this->view->key = $key; return $this->view->render(); }
/** * Allows the user to change their password after a password reset email. * @param $userId * @param $key * @return string */ public function resetPassword($userId, $key) { $user = $this->userStore->getById($userId); $userKey = md5(date('Y-m-d') . $user->getHash()); if (empty($user) || $key != $userKey) { $this->view->error = Lang::get('reset_invalid'); return $this->view->render(); } if ($this->request->getMethod() == 'POST') { $hash = password_hash($this->getParam('password'), PASSWORD_DEFAULT); $user->setHash($hash); $_SESSION['phpci_user'] = $this->userStore->save($user); $_SESSION['phpci_user_id'] = $user->getId(); $response = new b8\Http\Response\RedirectResponse(); $response->setHeader('Location', PHPCI_URL); return $response; } $this->view->id = $userId; $this->view->key = $key; return $this->view->render(); }