From 524871ab5251c65f59aab0913624aad5f06fd2e5 Mon Sep 17 00:00:00 2001 From: Iglocska Date: Sat, 14 Mar 2015 08:35:24 +0100 Subject: [PATCH] Sync users should default to termsaccepted and no password change required, fixes #432 --- app/Controller/UsersController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Controller/UsersController.php b/app/Controller/UsersController.php index 0cb273129..0eaa31b73 100755 --- a/app/Controller/UsersController.php +++ b/app/Controller/UsersController.php @@ -326,14 +326,20 @@ class UsersController extends AppController { if ($this->request->is('post')) { $this->User->create(); // set invited by + $this->loadModel('Role'); + $this->Role->recursive = -1; + $chosenRole = $this->Role->findById($this->request->data['User']['role_id']); $this->request->data['User']['invited_by'] = $this->Auth->user('id'); - $this->request->data['User']['change_pw'] = 1; + if ($chosenRole['Role']['perm_sync']) { + $this->request->data['User']['change_pw'] = 0; + $this->request->data['User']['termsaccepted'] = 1; + } else { + $this->request->data['User']['change_pw'] = 1; + $this->request->data['User']['termsaccepted'] = 0; + } $this->request->data['User']['newsread'] = '2000-01-01'; if (!$this->_isSiteAdmin()) { $this->request->data['User']['org'] = $this->Auth->User('org'); - $this->loadModel('Role'); - $this->Role->recursive = -1; - $chosenRole = $this->Role->findById($this->request->data['User']['role_id']); if ($chosenRole['Role']['perm_site_admin'] == 1 || $chosenRole['Role']['perm_regexp_access'] == 1 || $chosenRole['Role']['perm_sync'] == 1) { throw new Exception('You are not authorised to assign that role to a user.'); }