/** * Deletes a users account. * * @param string $password * * @throws Exception */ public function delete($password) { if (!$this->isAuthenticated()) { // User is not authenticated throw new \Exception('not_authenticated'); } // Validate password Model\User::validatePassword($password); if (!$this->authenticatedUser->verifyPassword($password)) { // User's password is incorrect throw new \Exception('password_incorrect'); } // Delete the user from the database $this->database->deleteUser($this->authenticatedUser->getId()); $this->addLog("user.delete"); // Logout the user $this->logout(); }