diff options
Diffstat (limited to 'app/php/facades')
-rw-r--r-- | app/php/facades/UserFacade.php | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/php/facades/UserFacade.php b/app/php/facades/UserFacade.php index 3e32a8d..69d634a 100644 --- a/app/php/facades/UserFacade.php +++ b/app/php/facades/UserFacade.php @@ -16,12 +16,20 @@ class UserFacade extends Facade { } public function registerUser($login, $password, $admin) { - $newUser = new User(); - $newUser->Login = $login; - $newUser->Password = $this->generatePassword($password); - $newUser->IsAdmin = $admin; - $newUser->save(); - return $newUser; + $transaction = $this->beginTransaction(); + try { + $newUser = new User(); + $newUser->Login = $login; + $newUser->Password = $this->generatePassword($password); + $newUser->IsAdmin = $admin; + $newUser->save(); + $this->raiseEvent('UserRegistered', $newUser); + $transaction->commit(); + return $newUser; + } catch (Exception $e) { + $transaction->rollback(); + throw $e; + } } public function changePassword(DbUser $user, $pass) { |