diff options
author | Michael Francis <edude03@gmail.com> | 2011-07-06 18:13:26 -0400 |
---|---|---|
committer | Michael Francis <edude03@gmail.com> | 2011-07-06 18:13:26 -0400 |
commit | 50c66c5b5ff73aa9893337dcdefb8d57381fe34c (patch) | |
tree | 42b9bcb613fc7ea1cbaf65a238547bb46ac5633e /controllers/UsersController.php | |
parent | 81ac4d6fff2b7350a2942e9b84fc8a42e16e8d35 (diff) | |
download | otakuhub-50c66c5b5ff73aa9893337dcdefb8d57381fe34c.tar.xz |
Cleaned up code and make sure that the $user returns
Diffstat (limited to 'controllers/UsersController.php')
-rw-r--r-- | controllers/UsersController.php | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/controllers/UsersController.php b/controllers/UsersController.php index d1b3193..e6e0675 100644 --- a/controllers/UsersController.php +++ b/controllers/UsersController.php @@ -226,50 +226,36 @@ class UsersController extends \lithium\action\Controller { public function signup() { + $user = null; //If the request isn't empty if($this->request->data) { //Create a user from the data $user = User::Create($this->request->data); - - //Until the save bug is fixed - $results = $user->validates(); - - if ($results) - { - //The user isn't active until after they confirm. - $user->confirmed = false; - $user->active = false; - $user->joinedOn = new MongoDate(); + //The user isn't active until after they confirm. + $user->confirmed = false; + $user->active = false; + $user->joinedOn = new MongoDate(); + + //By default save does validation at the same time, + //If there are errors its stuffs them into the $user->_erorrs variable, + //Accessible from $user->errors(), this is automatically passed to the view. + if ($user->save()) + { //Generate a confirmation key for the user $key = confirmKey::Create(array('key' => confirmKey::generate($user->email), 'username' => $user->username)); //Save it to the database $key->save(); - - //If everything goes ok - if ($user->save(null, array('validates' => false))) - { - //Store some session information - //Session::write('username', $user->username); - //Session::write('email', $user->email); - - //For the debug version, send the key to the front page - $link = "/users/confirm"; - return compact('key', 'link'); - - // /* - // //Send them to the confirmation page. - // $this->redirect('users/confirm'); - - } - } - else - { - return compact('user'); + + //For testing, we return the link to the view, so they can click it, + //This will be replaced with an email in production + $link = "/users/confirm"; + return compact('key', 'link', 'user'); } } + return compact('user'); } /* |