Compare commits

...

2 commits

Author SHA1 Message Date
3d9decdafd Auth Ldap: Fix typo 2023-02-25 14:49:45 +01:00
33fcd6a92c User: add __toString() magic method 2023-02-25 14:49:39 +01:00
3 changed files with 12 additions and 2 deletions

View file

@ -235,7 +235,7 @@ class Ldap extends Backend {
);
}
Log::debug('User "%s" found in LDAP directory (%s):\n%s', $username, $dn, vardump($info));
return new User($username, '\\EesyPHP\\Auth\\LDAP', $info);
return new User($username, '\\EesyPHP\\Auth\\Ldap', $info);
}
/**

View file

@ -83,4 +83,14 @@ class User {
);
}
/**
* Magic method to allow pretty cast to string
* @return string
*/
public function __toString() {
if (isset($this -> name))
return sprintf('%s (%s)', $this -> name, $this -> username);
return $this -> namename;
}
}

View file

@ -163,7 +163,7 @@ class Log {
$_SERVER['REMOTE_ADDR'],
);
if (Auth::enabled())
$msg[] = (Auth::user()?Auth::user()->username:'anonymous');
$msg[] = (Auth::user()?Auth::user():'anonymous');
$msg[] = $level;
$msg[] = $message;
$msg = implode(' - ', $msg)."\n";