public static function createUser()
 {
     $params = $_POST;
     $sign_up_form = new SignUpForm(array('first_name' => $params['first_name'], 'last_name' => $params['last_name'], 'email' => $params['email'], 'password' => $params['password'], 'password_confirmation' => $params['password_confirmation']));
     if ($sign_up_form->validate()) {
         $user = new User((array) $sign_up_form);
         $user->save();
         $_SESSION['user'] = $user->id;
         Redirect::to('/units', array('message' => 'Welcome ' . $user->first_name . "!"));
     } else {
         $errors = array_values($sign_up_form->errors());
         Redirect::to('/', array('errors' => $errors, 'input' => $params));
     }
 }
Beispiel #2
0
 /**
  * execute the signup ation, face to an existent user.
  */
 public function signupAction()
 {
     $form = new SignUpForm();
     if ($this->request->isPost()) {
         if ($form->isValid($this->request->getPost()) != false) {
             $user = new User();
             $user->assign(array('username' => $this->request->getPost('name', 'striptags'), 'password' => $this->security->hash($this->request->getPost('password')), 'email' => $this->request->getPost('email'), 'active' => 0, 'token' => "false"));
             if ($user->save()) {
                 return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
             } else {
                 echo "<h5>Upps! Data couldn't be saved :(... Try again...</h5>";
             }
             $this->flash->error($user->getMessages());
         }
     }
     $this->view->form = $form;
 }
 public function signUpAction()
 {
     $form = new SignUpForm();
     $this->view->form = $form;
     if (isset($_POST)) {
         if ($form->isValid($_POST)) {
             $user = new UserModel();
             $user->populate($_POST);
             $user->save();
         } else {
             foreach ($form->getMessages() as $message) {
                 $this->flash->error($message);
             }
         }
         // $this->view->disable();
     }
 }
Beispiel #4
0
 public function actionSignup()
 {
     $model = new SignUpForm();
     if (isset($_POST['SignUpForm'])) {
         $model->attributes = $_POST['SignUpForm'];
         if ($model->validate()) {
             $user = new FrontendUser();
             $user->username = $model->email;
             $user->email = $model->email;
             $user->password = $model->password;
             $isExist = FrontendUser::model()->find(array('condition' => 'email = :email OR username = :username', 'params' => array(':email' => $user->email, ':username' => $user->email)));
             if ($isExist) {
                 echo json_encode(array('status' => 'error', 'error' => 'Пользователь с указанным e-mail уже зарегистрирован на сайте'));
             } elseif ($user->save()) {
                 EmailManager::sendUserInfo($user, $model->password);
                 echo '{"status" : "ok"}';
             } else {
                 echo json_encode(array('status' => 'error', 'error' => CHtml::errorSummary($user)));
             }
         } else {
             echo json_encode(array('status' => 'error', 'error' => CHtml::errorSummary($model)));
         }
     }
 }