Merge pull request #475 from MrPetovan/task/4041-fix-register

Use Exceptions for User::create
pull/477/head
Tobias Diekershoff 2017-12-13 10:37:24 +01:00 committed by GitHub
commit 726db2c83f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -177,11 +177,12 @@ function ldap_autocreateaccount($ldap_autocreateaccount, $username, $password, $
if (empty($results)) {
if (strlen($email) > 0 && strlen($name) > 0) {
$arr = array('username' => $name, 'nickname' => $username, 'email' => $email, 'password' => $password, 'verified' => 1);
$result = User::create($arr);
if ($result['success']) {
try {
User::create($arr);
logger("ldapauth: account " . $username . " created");
} else {
logger("ldapauth: account " . $username . " was not created ! : " . implode($result));
} catch (Exception $ex) {
logger("ldapauth: account " . $username . " was not created ! : " . $ex->getMessage());
}
} else {
logger("ldapauth: unable to create account, no email or nickname found");