|
|
@@ -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');
|
|
|
}
|
|
|
|
|
|
/*
|