public function actionCreate() { $model = new SignupForm(); $parseData['model'] = $model; // get user types $types = $model->_types; $role = new Role(); if ($role->isAdmin) { foreach ($types as $key => $value) { if ($value['value'] == User::TYPE_ADMIN) { unset($types[$key]); } } } $parseData['types'] = $model->_prepareDataSelect($types, 'value', 'label'); $post = Yii::$app->request->post(); if ($post) { $model->load(Yii::$app->request->post()); if ($model->validate()) { $model->signup(); return $this->redirect(['index']); } else { $parseData['errors'] = $model->getErrors(); } } return $this->render('create', $parseData); }
public function actionSignUp() { $model = new SignupForm(); if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->validate()) { $user = $model->signup(); if ($user) { Yii::$app->user->login($user, 3600 * 24 * 30); $response = ['access_token' => Yii::$app->user->identity->getAuthKey(), 'flash' => ['class' => 'success', 'message' => 'Thank you. You are successfully sign up.']]; } else { $response = ['flash' => ['class' => 'error', 'message' => 'Something wrong.']]; } return $response; } else { $model->validate(); return $model; } }
public function actionRegister() { $registerForm = new SignupForm(); if ($registerForm->load(\Yii::$app->request->post()) && $registerForm->validate()) { /* \Yii::$app->common->sendMail(Html::encode($registerForm->email), Html::encode($registerForm->username), Html::encode($registerForm->password_hash)); $userModel = new UserDbModel(); $userModel->username = Html::encode($registerForm->username); $userModel->email = Html::encode($registerForm->email); $userModel->password_hash = \Yii::$app->security->generatePasswordHash(Html::encode($registerForm->password_hash)); $userModel->generateAuthKey(); $userModel->save(); //*/ $registerForm->signup(); return $this->render('registerView', ['formModel' => $registerForm, 'success' => true]); } else { return $this->render('registerView', ['formModel' => $registerForm]); } }
/** * The signup page * @return string|\yii\web\Response */ public function actionSignup() { //$this->layout = 'main'; $this->layout = 'login'; $model = new SignupForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($this->createUser(['name' => $model->name, 'email' => $model->email])) { Yii::$app->session->setFlash('success', Yii::t('app', 'Your account as been created successfully. Please check your email for login instructions.')); return $this->redirect(Yii::$app->user->loginUrl); } else { Yii::$app->session->setFlash('error', Yii::t('app', 'Sorry, something went wrong. We\'re working on getting this fixed as soon as we can.')); } } return $this->render('signup', ['model' => $model]); }
public function actionRegisterStore() { $this->layout = 't2/main'; $userModel = new SignupForm(); $storeModel = new Store(); $user_id = 0; if ($userModel->load(Yii::$app->request->post()) && $storeModel->load(Yii::$app->request->post())) { // print_r($storeModel->validate()); exit; if (Yii::$app->user->isGuest) { if ($userModel->validate() && ($user = $userModel->signup())) { $user_id = $user->id; } else { return $this->render('registerStore', ['userModel' => $userModel, 'storeModel' => $storeModel]); } } else { $user_id = \Yii::$app->user->identity->id; } $store_img = UploadedFile::getInstances($storeModel, 'file'); if ($storeModel->validate()) { if (!empty($store_img)) { $storeModel->file = $store_img[0]; $image_name = '/store/' . $storeModel->file->baseName . '_' . time() . '.' . $storeModel->file->extension; $image_path = Yii::getAlias('@frontend') . '/web/uploads' . $image_name; $storeModel->file->saveAs($image_path); $storeModel->store_picture = $image_name; } if ($storeModel->save()) { $store_id = $storeModel->store_id; $userStore = new UserStore(); $userStore->user_id = $user_id; $userStore->store_id = $store_id; $userStore->save(); return $this->redirect(Yii::$app->urlManager->getBaseUrl() . '/backend/web/'); } else { print_r($storeModel->error); exit; } // } } else { print_r($storeModel->errors); exit; return $this->render('registerStore', ['userModel' => $userModel, 'storeModel' => $storeModel]); } echo '<pre>'; print_r($storeModel); print_r($store_img); exit; } // $store_img = UploadedFile::getInstances($storeModel, 'file'); // $storeModel->file = $store_img[0]; // if($storeModel->validate()) { // if(!empty($store_img)){ // $image_name = '/store/' . $storeModel->file->baseName . '_' . time() . '.' . $storeModel->file->extension; // $image_path = Yii::getAlias('@frontend'). '/web/uploads' . $image_name; // $storeModel->file->saveAs( $image_path); // $storeModel->store_picture = $image_name; // if($storeModel->save()) { // $store_id = $storeModel->store_id; // $user_id = \Yii::$app->user->identity->id; // echo $store_id; // echo $user_id; // exit; // } // } // // return $this->redirect(['view', 'id' => $model->store_id]); // } else { // // return $this->render('update', [ // // 'model' => $model, // // ]); // } return $this->render('registerStore', ['userModel' => $userModel, 'storeModel' => $storeModel]); }
public function actionSubmitSignup() { $model = new SignupForm(); $model->setScenario('user-create'); $submitResponse[] = ''; if ($model->load(Yii::$app->request->post())) { Yii::$app->response->format = 'json'; if ($model->validate() && $model->signup()) { $model->sendEmailActivation(); $submitResponse = ['isSuccess' => true, 'message' => 'Registrasi Berhasil, Silahkan aktifkan akun anda melalui email.']; return $submitResponse; } else { $submitResponse = ['isSuccess' => false, 'message' => 'Registrasi Gagal']; echo $submitResponse; } } }
public function actionSignup() { $model = new SignupForm(); Yii::$app->response->format = 'json'; if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->sendEmail(Yii::$app->params['contactEmail'])) { return ['message' => Yii::t('app', 'Thank you for your interest. We will respond to you as soon as possible.'), 'status' => 'success']; } else { return ['message' => Yii::t('app', 'There was an error during request.'), 'status' => 'error']; } } else { return ['message' => Yii::t('app', 'There was an error during processing your inputs.'), 'status' => 'error']; } }
public function actionExist() { $params = Yii::$app->getRequest()->getBodyParams(); $user = User::findByUsername($params); if (!$user) { $model = new SignupForm(); $isLoad = $model->load($params, ''); $user = $model->signup(); if ($isLoad && $user) { Yii::$app->user->login($user); return ['access_token' => $user->getAuthKey(), 'user_id' => $user->getId()]; } else { $model->validate(); return $model; } } else { Yii::$app->user->login($user); return ['access_token' => $user->getAuthKey(), 'user_id' => $user->getId()]; } return null; }
/** * Signs user up. * * @return mixed */ public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($user = $model->signup()) { //if (Yii::$app->getUser()->login($user)) { return $this->goHome(); //} } } else { return $this->render('signup', ['model' => $model]); } }