Fix login and logout
This commit is contained in:
parent
aabce87d03
commit
f53f95381a
19
start.php
19
start.php
|
@ -28,9 +28,11 @@
|
|||
$elgg_user = saml_map_attributes($attributes);
|
||||
if ($isAuth && ! isloggedin() && $elgg_user)
|
||||
{
|
||||
if ($user = get_entities_from_metadata('ldapDN', $dn, 'user')) {
|
||||
|
||||
if ($user = get_entities_from_metadata('ldapDN', $elgg_user['ldapDN'], 'user')) {
|
||||
$user = $user[0];
|
||||
}
|
||||
error_log('SAMLAuth found user "' . $user . '" for ldapDN "' . $elgg_user['ldapDN'] . '"');
|
||||
if (! $user)
|
||||
{
|
||||
try {
|
||||
|
@ -45,10 +47,17 @@
|
|||
}
|
||||
else
|
||||
saml_sync_user($user, $elgg_user);
|
||||
if ($user)
|
||||
return login($user);
|
||||
if ($user) {
|
||||
$result = login($user);
|
||||
$_SESSION['saml_user'] = TRUE;
|
||||
return $result;
|
||||
}
|
||||
// XXX: else return an error ?
|
||||
}
|
||||
if (! $isAuth && isloggedin() && $_SESSION['saml_user']) {
|
||||
// unlogged from simplesamlphp but not from elgg
|
||||
return logout();
|
||||
}
|
||||
}
|
||||
|
||||
function init_config()
|
||||
|
@ -100,7 +109,9 @@
|
|||
$elgg_user['username'] = $attributes[$config->username][0];
|
||||
$elgg_user['password'] = gen_rand_pwd();
|
||||
$elgg_user['name'] = '';
|
||||
$elgg_user['ldapDN'] = $attributes['dn'];
|
||||
if ($attributes['dn']) {
|
||||
$elgg_user['ldapDN'] = $attributes['dn'][0];
|
||||
}
|
||||
if ($attributes[$config->surname] || $attributes[$config->firstname])
|
||||
{
|
||||
if ($attributes[$config->firstname])
|
||||
|
|
Reference in New Issue