Archived
1
0
Fork 0

Merge branch '14-user-add-support-for-removing-account' into dev

This commit is contained in:
Henrik Hautakoski 2018-08-13 01:11:52 +02:00
commit 6d8025c5d6
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA
7 changed files with 95 additions and 3 deletions

View file

@ -6,6 +6,7 @@ use App\Controller\ControllerBase,
App\Form\UserSettings as UserSettingsForm,
App\Model\Data\ActivityLog,
App\Model\Data\PasswordLink,
App\Model\Data\User,
SendGrid\Mail\Mail as SendGridMail;
class UserController extends ControllerBase
@ -79,6 +80,37 @@ class UserController extends ControllerBase
$this->view->form = $form;
}
public function deleteAction()
{
$user = $this->_getAuth()->getUser();
if ($this->request->isPost()) {
$data = $this->request->getPost();
}
// Delete acc.
if (isset($data['deleteAcc'])) {
if (strlen($user->getPassword()) > 0) {
if (!isset($data['currentpw']) || !$this->security->checkHash($data['currentpw'], $user->getPassword())) {
$this->flash->error('The password was not correct. Refusing to delete account.');
$this->response->redirect('/settings');
return;
}
}
$user->setStatus(User::STATUS_DELETED);
$user->save();
// Logout the user.
$this->auth->clearIdentity();
$this->flash->success('The account was successfully removed.');
}
$this->response->redirect('/settings');
}
/**
* Activate a password.
*