summaryrefslogtreecommitdiff
path: root/app/php/facades
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-06 17:13:32 +0200
committeremkael <emkael@tlen.pl>2016-05-06 17:13:32 +0200
commit8f3e62ac9365880ef7688504065a6e472505e344 (patch)
treebf63fde9459036dbbf232e3aaf89bc8154cce6df /app/php/facades
parenta69844e2640d559ecd78fbe39d1bcadc1cb53d15 (diff)
* cloning default calendar preference for new users
Diffstat (limited to 'app/php/facades')
-rw-r--r--app/php/facades/UserFacade.php20
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) {