diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-12-31 12:37:15 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-12-31 12:37:15 -0500 |
commit | 772804add8095eea9b3ec2a832c2f82fbb9a6fd5 (patch) | |
tree | 782a414d15f9091d04bcf3960a957f952958e548 /app/Controller/User.php | |
parent | 66f150d887a34d2b51ff14f22d0fd41a34f8cc77 (diff) |
Acl refactoring
Diffstat (limited to 'app/Controller/User.php')
-rw-r--r-- | app/Controller/User.php | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/app/Controller/User.php b/app/Controller/User.php index 619bbc90..00c2f104 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -18,7 +18,7 @@ class User extends Base public function logout() { $this->checkCSRFParam(); - $this->authentication->backend('rememberMe')->destroy($this->acl->getUserId()); + $this->authentication->backend('rememberMe')->destroy($this->userSession->getId()); $this->session->close(); $this->response->redirect('?controller=user&action=login'); } @@ -30,7 +30,7 @@ class User extends Base */ public function login(array $values = array(), array $errors = array()) { - if ($this->acl->isLogged()) { + if ($this->userSession->isLogged()) { $this->response->redirect('?controller=app'); } @@ -78,7 +78,7 @@ class User extends Base { $content = $this->template->render($template, $params); $params['user_content_for_layout'] = $content; - $params['board_selector'] = $this->projectPermission->getAllowedProjects($this->acl->getUserId()); + $params['board_selector'] = $this->projectPermission->getAllowedProjects($this->userSession->getId()); if (isset($params['user'])) { $params['title'] = ($params['user']['name'] ?: $params['user']['username']).' (#'.$params['user']['id'].')'; @@ -101,7 +101,7 @@ class User extends Base $this->notfound(); } - if ($this->acl->isRegularUser() && $this->acl->getUserId() != $user['id']) { + if (! $this->userSession->isAdmin() && $this->userSession->getId() != $user['id']) { $this->forbidden(); } @@ -125,7 +125,7 @@ class User extends Base $this->response->html( $this->template->layout('user/index', array( - 'board_selector' => $this->projectPermission->getAllowedProjects($this->acl->getUserId()), + 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()), 'projects' => $this->project->getList(), 'nb_users' => $nb_users, 'users' => $users, @@ -151,7 +151,7 @@ class User extends Base public function create(array $values = array(), array $errors = array()) { $this->response->html($this->template->layout('user/new', array( - 'board_selector' => $this->projectPermission->getAllowedProjects($this->acl->getUserId()), + 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()), 'projects' => $this->project->getList(), 'errors' => $errors, 'values' => $values, @@ -328,7 +328,7 @@ class User extends Base $values = $this->request->getValues(); - if ($this->acl->isAdminUser()) { + if ($this->userSession->isAdmin()) { $values += array('is_admin' => 0); } else { @@ -404,16 +404,16 @@ class User extends Base if (is_array($profile)) { // If the user is already logged, link the account otherwise authenticate - if ($this->acl->isLogged()) { + if ($this->userSession->isLogged()) { - if ($this->authentication->backend('google')->updateUser($this->acl->getUserId(), $profile)) { + if ($this->authentication->backend('google')->updateUser($this->userSession->getId(), $profile)) { $this->session->flash(t('Your Google Account is linked to your profile successfully.')); } else { $this->session->flashError(t('Unable to link your Google Account.')); } - $this->response->redirect('?controller=user&action=external&user_id='.$this->acl->getUserId()); + $this->response->redirect('?controller=user&action=external&user_id='.$this->userSession->getId()); } else if ($this->authentication->backend('google')->authenticate($profile['id'])) { $this->response->redirect('?controller=app'); @@ -441,14 +441,14 @@ class User extends Base public function unlinkGoogle() { $this->checkCSRFParam(); - if ($this->authentication->backend('google')->unlink($this->acl->getUserId())) { + if ($this->authentication->backend('google')->unlink($this->userSession->getId())) { $this->session->flash(t('Your Google Account is not linked anymore to your profile.')); } else { $this->session->flashError(t('Unable to unlink your Google Account.')); } - $this->response->redirect('?controller=user&action=external&user_id='.$this->acl->getUserId()); + $this->response->redirect('?controller=user&action=external&user_id='.$this->userSession->getId()); } /** @@ -466,16 +466,16 @@ class User extends Base if (is_array($profile)) { // If the user is already logged, link the account otherwise authenticate - if ($this->acl->isLogged()) { + if ($this->userSession->isLogged()) { - if ($this->authentication->backend('gitHub')->updateUser($this->acl->getUserId(), $profile)) { + if ($this->authentication->backend('gitHub')->updateUser($this->userSession->getId(), $profile)) { $this->session->flash(t('Your GitHub account was successfully linked to your profile.')); } else { $this->session->flashError(t('Unable to link your GitHub Account.')); } - $this->response->redirect('?controller=user&action=external&user_id='.$this->acl->getUserId()); + $this->response->redirect('?controller=user&action=external&user_id='.$this->userSession->getId()); } else if ($this->authentication->backend('gitHub')->authenticate($profile['id'])) { $this->response->redirect('?controller=app'); @@ -506,13 +506,13 @@ class User extends Base $this->authentication->backend('gitHub')->revokeGitHubAccess(); - if ($this->authentication->backend('gitHub')->unlink($this->acl->getUserId())) { + if ($this->authentication->backend('gitHub')->unlink($this->userSession->getId())) { $this->session->flash(t('Your GitHub account is no longer linked to your profile.')); } else { $this->session->flashError(t('Unable to unlink your GitHub Account.')); } - $this->response->redirect('?controller=user&action=external&user_id='.$this->acl->getUserId()); + $this->response->redirect('?controller=user&action=external&user_id='.$this->userSession->getId()); } } |