/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { // print_r($_POST); // die(); $pass = Yii::$app->security->generatePasswordHash($_POST['User']['password']); $model->password_hash = $pass; $content = ' <center><img src="http://i.imgur.com/rkxzCKf.png"/></center><br/> <h4 align="center">Sekolah Tinggi Terpadu Nurul Fikri ' . date('Y') . '</h4> <hr/> <p>Yth ' . $model->username . ',<br/> Dengan ini kami sampaikan password telah direset sebagai berikut:<br/> Username : '******' <br/> Password :<b>' . $_POST['User']['password'] . '</b><br/> Mohon lakukan penggantian password Anda setelah melakukan login. <hr/> <h5 align="center">Developer By Hendra Aditya Wijaya Mentor Ilham Malik Ibrahim' . date('Y') . '</h5><br/>'; Yii::$app->mailer->compose("@common/mail/layouts/html", ["content" => $content])->setTo($_POST['User']['email'])->setFrom([$_POST['User']['email'] => 'Aplikasi Simpel Bapeten'])->setSubject('Ubah Kata Sandi')->setTextBody($_POST['User']['password'])->send(); $model->save(); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model]); } }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(['scenario' => 'admin-create']); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->authManager->assign(Yii::$app->authManager->getRole($model->role), $model->id); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { //if(!Yii::$app->user->can('createUser')) throw new ForbiddenHttpException(Yii::t('app', 'No Auth')); $model = new User(['scenario' => 'admin-create']); if ($model->load(Yii::$app->request->post()) && $model->save()) { //Yii::$app->authManager->assign(Yii::$app->authManager->getRole($model->role), $model->id); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(); if ($model->load(Yii::$app->request->post()) && $model->save()) { // Yii::$app->Controllers->activity_user("[CREATE COS]"); Yii::$app->Controllers->historyUserWithData($model); echo 1; } else { return $this->renderAjax('create', ['model' => $model]); } }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(); if ($model->load(Yii::$app->request->post())) { $model->auth_key = Yii::$app->security->generateRandomString(); $model->password_hash = Yii::$app->security->generatePasswordHash($model->newpass); $model->password_reset_token = NULL; $model->save(); $this->actionApprole($model->id, 'user'); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'admin' => true]); } }
/** * 创建用户 * * @return mixed */ public function actionCreate() { $model = new User(); if ($model->load(Yii::$app->request->post())) { $model->setPassword('123456'); $model->generateAuthKey(); //$model->signup(); $ret = $model->save(); if ($ret) { return $this->redirect(['index']); } } return $this->render('create', ['model' => $model]); }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(); if (Yii::$app->request->isPost) { $model->load(Yii::$app->request->post()); if ($model->save()) { $userdata = new WooUserData(); $userdata->user_id = $model->id; $userdata->user_name = "Unset"; $userdata->user_lastname = "Unset"; $model->link("woouserdata", $userdata); return $this->redirect(['view', 'id' => $model->id]); } } else { return $this->render('create', ['model' => $model]); } }
/** * function ::create ($data) */ public static function create($data) { $now = strtotime('now'); $username = Yii::$app->user->identity->username; $model = new User(); if ($model->load($data)) { if ($log = new UserLog()) { $log->username = $username; $log->action = "Create"; $log->object_class = "User"; $log->created_at = $now; $log->is_success = 0; $log->save(); } $model->created_at = $now; $model->dob = strtotime($model->dob); do { $path = FileUtils::generatePath($now); } while (file_exists(Yii::$app->params['images_folder'] . $path)); $model->image_path = $path; $targetFolder = Yii::$app->params['images_folder'] . $model->image_path; $targetUrl = Yii::$app->params['images_url'] . $model->image_path; if (!empty($data['user-image'])) { $copyResult = FileUtils::copyImage(['imageName' => $model->image, 'fromFolder' => Yii::$app->params['uploads_folder'], 'toFolder' => $targetFolder, 'resize' => [[120, 120], [200, 200]], 'resizeType' => 2, 'removeInputImage' => true]); if ($copyResult['success']) { $model->image = $copyResult['imageName']; } } // User class $model->generateAuthKey(); $model->setPassword($model->password); if ($model->save()) { if ($log) { $log->object_pk = $model->id; $log->is_success = 1; $log->save(); } return $model; } $model->getErrors(); return $model; } return false; }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(); $model->scenario = 'create'; if ($model->load(Yii::$app->request->post())) { $image = $model->uploadImage(); if ($model->save()) { // upload only if valid uploaded file instance found if ($image !== false) { $path = $model->getImageFile(); $image->saveAs($path); } return $this->redirect(['view', 'id' => $model->id]); } else { } } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if (Yii::$app->user->can('createUser')) { $model = new User(); if ($model->load(Yii::$app->request->post())) { $lastInsertID = $model->getPrimaryKey(); $model->id = $lastInsertID; $model->password_hash = Yii::$app->security->generatePasswordHash($_POST['User']['password_hash']); $model->created_at = time(); $model->updated_at = time(); $model->save(false); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } } else { throw new ForbiddenHttpException(); } }
public function actionCreate() { $error = ''; $model = new User(); $data['_csrf'] = Yii::$app->request->post('_csrf', ''); $data['User'] = Yii::$app->request->post(); if (isset($data['User']['submit'])) { $error .= empty($data['User']['username']) ? '<p> - Username không được bỏ trống </p>' : ''; $error .= empty($data['User']['full_name']) ? '<p> - Full_name không được bỏ trống </p>' : ''; $error .= empty($data['User']['password']) ? '<p> - Password không được bỏ trống </p>' : ''; $error .= empty($data['User']['re-password']) ? '<p> - Re-password không được bỏ trống </p>' : ''; $error .= empty($data['User']['email']) ? '<p> - Email không được bỏ trống </p>' : ''; if (!empty($data['User']['password']) && !empty($data['User']['re-password'])) { $error .= $data['User']['password'] != $data['User']['re-password'] ? '<p> - Password nhập lại không chính xác' : ''; } $checkUsername = $model->findByUsername($data['User']['username']); $checkEmail = $model->findByEmail($data['User']['email']); $error .= !empty($checkUsername) ? '<p> - Username đã tồn tại </p>' : ''; $error .= !empty($checkEmail) ? '<p> - Email đã được sử dụng </p>' : ''; $data['User']['create_date'] = time(); $data['User']['user_create'] = \Yii::$app->user->id; $data['User']['password'] = md5(md5($data['User']['password']) . 'cinefun2015'); } if (empty($error) && $model->load($data) && $model->save()) { $user = $model->findByUsername($data['User']['username']); $id = $user->id; $auth = new AuthAssignment(); $dataAuth['_csrf'] = $data['_csrf']; $dataAuth['AuthAssignment']['item_name'] = $data['User']['group']; $dataAuth['AuthAssignment']['user_id'] = $id; $dataAuth['AuthAssignment']['created_at'] = time(); $auth->load($dataAuth); $auth->save(); return $this->redirect(['index']); } else { $group = $model->getGroup(); return $this->render('create', ['group' => $group, 'error' => $error]); } }
/** * Creates a new User model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(); $pi = new PersonalInformation(); if ($pi->load(Yii::$app->request->post())) { /*print_r($this->pi_name); die();*/ /*$pi = new PersonalInformation(); $pi->load(Yii::$app->request->post());*/ $pi->pi_name = $pi->pi_name; $pi->save(); if ($pi->save() == 1) { // this is inserted user id //$model = new User(); $model->load(Yii::$app->request->post()); /*print_r($model); //print_r($pi); die();*/ $userID = $pi->pi_id; $model->pi_id = $userID; $model->username = $model->username; $model->status = $model->status; $model->online_status = "0"; $model->created_at = time(); $model->updated_at = time(); $model->auth_key = "vBZS7KGrvXesyOkgQhGYCY5KCZi6st5g"; $model->password_hash = "\$2y\$13\$4cRqqw0nmEj5.NJRcJYaE.YUSh9DJaQsSpLM3OCicXckrCPoAgWYC"; $model->save(); /*print_r($model->getErrors()); die();*/ } return $this->redirect(['index', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Action to reset password from admin. * @param int $id * @return mixed */ public function actionReset($id) { $model1 = $this->findModel($id); $model = new User(); if ($model->load(Yii::$app->request->post())) { $password = $_POST['password']; $hash = Yii::$app->getSecurity()->generatePasswordHash($password); $model->password_hash = $hash; $sql = "update user set password_hash='{$hash}' where id='{$id}'"; $res = Yii::$app->db->createCommand($sql)->execute(); Yii::$app->session->setFlash('success', 'Password Sucessfully Reset'); } return $this->render('reset', ['model' => $this->findModel($id), 'model1' => $model]); }