diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2017-08-23 16:49:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-23 16:49:57 +0200 |
commit | 9357cf735a2ffbbd1291cfd8480cbc2342c361f7 (patch) | |
tree | 86b13c65f99d2a7eaed795e9376a8ee5ceeac19d /lib | |
parent | 4225f938182a0b998d620d278b32a42660a6d032 (diff) | |
parent | ed8a98eaa1e44d172b838c5c9caa74261ac27eb1 (diff) | |
download | nextcloud-server-9357cf735a2ffbbd1291cfd8480cbc2342c361f7.tar.gz nextcloud-server-9357cf735a2ffbbd1291cfd8480cbc2342c361f7.zip |
Merge pull request #6164 from nextcloud/dont-show-error-message-when-sql-failed
Prevent SQL error message in case of error
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/User/Database.php | 6 | ||||
-rw-r--r-- | lib/private/User/Manager.php | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 73506c7d7c5..79032cfd405 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -92,7 +92,11 @@ class Database extends Backend implements IUserBackend { $event = new GenericEvent($password); $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event); $query = \OC_DB::prepare('INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )'); - $result = $query->execute(array($uid, \OC::$server->getHasher()->hash($password))); + try { + $result = $query->execute(array($uid, \OC::$server->getHasher()->hash($password))); + } catch (\Exception $e) { + $result = false; + } // Clear cache unset($this->cache[$uid]); diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 8f3c98d4b5e..6b6c10ab295 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -349,7 +349,10 @@ class Manager extends PublicEmitter implements IUserManager { } $this->emit('\OC\User', 'preCreateUser', [$uid, $password]); - $backend->createUser($uid, $password); + $state = $backend->createUser($uid, $password); + if($state === false) { + throw new \InvalidArgumentException($l->t('Could not create user')); + } $user = $this->getUserObject($uid, $backend); if ($user instanceof IUser) { $this->emit('\OC\User', 'postCreateUser', [$user, $password]); |