Ejemplo n.º 1
0
 /**
  * Signs user up.
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             $Verification = new UserVerified();
             $Verification->user_id = $user->id;
             $Verification->key = sha1($user->username . time() . uniqid());
             if ($Verification->save()) {
                 $this->signupNotification($user->email, $Verification->key);
                 return $user;
             }
         }
     }
     return null;
 }