disable user in case he has no roles

pull/2251/head
Thomas Stinner 2017-06-06 07:57:13 -07:00
parent a124de314c
commit f60a32cfa0
1 changed files with 13 additions and 4 deletions

View File

@ -128,6 +128,7 @@ class ApacheAuthenticate extends BaseAuthenticate {
// Set roleid depending on group membership
$roleIds = Configure::read('ApacheSecureAuth.ldapDefaultRoleId');
CakeLog::write("debug","RoleIDs: ". print_r($roleIds, true));
if (is_array($roleIds)) {
foreach ($roleIds as $key => $id) {
if ($this->isUserMemberOf($key, $ldapUserData)) {
@ -154,10 +155,18 @@ class ApacheAuthenticate extends BaseAuthenticate {
// save user
$userModel->save($userData, false);
} else {
// Update existing user
$user['email'] = $mispUsername;
$user['org_id'] = $org_id;
$user['role_id'] = $roleId;
if (!isset($roleId)) {
// User has no role anymore, disable user
$user['disabled'] = 1;
return false;
} else {
// Update existing user
$user['email'] = $mispUsername;
$user['org_id'] = $org_id;
$user['role_id'] = $roleId;
# Reenable user in case it has been disabled
$user['disabled'] = 0;
}
$userModel->save($user, false);
}