当前位置: 首页>>代码示例>>PHP>>正文


PHP User::setPassword方法代码示例

本文整理汇总了PHP中common\models\User::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setPassword方法的具体用法?PHP User::setPassword怎么用?PHP User::setPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common\models\User的用法示例。


在下文中一共展示了User::setPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: resetPassword

 public function resetPassword()
 {
     $this->_user = User::findIdentity(Yii::$app->user->id);
     if (!Yii::$app->getSecurity()->validatePassword($this->password, $this->_user->password_hash)) {
         throw new InvalidParamException(Yii::t('User', 'source_password_error'));
     }
     $this->_user->setPassword($this->new_password);
     return $this->_user->save(false);
 }
开发者ID:duanbiaowu,项目名称:sailshop,代码行数:9,代码来源:ResetPasswordForm.php

示例2: resetPassword

 /**
  * Resets password.
  *
  * @return boolean if password was reset.
  */
 public function resetPassword()
 {
     $this->_user->setPassword($this->password);
     $this->_user->removePasswordResetToken();
     if ($this->_user->save()) {
         $this->_user->sendPasswordChangedEmail();
         return true;
     }
     return false;
 }
开发者ID:rocketyang,项目名称:admap,代码行数:15,代码来源:ResetPasswordForm.php

示例3: signup

 /**
  * 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();
         $user->status = 0;
         if ($user->save()) {
             $notification = new Notification();
             $notification->title = 'user';
             $notification->message = 'new user, username:' . $user->username;
             $notification->params = \yii\helpers\Json::encode(['model' => 'User', 'id' => $user->id]);
             if ($notification->save()) {
                 $this->sendEmail($this->email);
             } else {
                 print_r($notification->getErrors());
                 exit(0);
             }
             return $user;
         } else {
             return $user->getErrors();
         }
     }
     return null;
 }
开发者ID:sintret,项目名称:yii2-advanced,代码行数:32,代码来源:SignupForm.php

示例4: signup

 /**
  * 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();
         $user->status = User::STATUS_NOTACTIVATED;
         $b = $user->save();
         $activationToken = new UserTokens();
         $activationToken->user_id = $user->id;
         $activationToken->token_type = ETokenType::ACCOUNT_ACTIVATION;
         $activationToken->token = sha1(mt_rand(10000, 99999) . time() . $user->email);
         $activationToken->save();
         $auth = Yii::$app->authManager;
         $userRole = $auth->getRole('user');
         $auth->assign($userRole, $user->id);
         if ($b) {
             $x = new UserInfo();
             $x->user_id = $user->id;
             $x->save();
             EventService::createEvent(EEvent::ACCOUNT_CREATE(), new UserId($user->id));
             $this->sendActivationMail($user, $activationToken->token);
             return $user;
         }
     }
     return null;
 }
开发者ID:lupi-stole-my-code,项目名称:nzi-project,代码行数:34,代码来源:SignupForm.php

示例5: signup

 /**
  * 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();
         //            Add field for project lifeguard 9/2015
         $user->code = $this->code;
         $user->referrer = $this->referrer;
         $user->first_name = $this->first_name;
         $user->last_name = $this->last_name;
         $user->sex = $this->sex;
         $user->graduate_high_school = $this->graduate_high_school;
         $user->city = $this->city;
         $user->state = $this->state;
         $user->zip = $this->zip;
         $user->mobile = $this->mobile;
         $user->status = $this->status;
         if (!$user->save()) {
             throw new ErrorException("Error save information user");
         }
         return $user;
     }
     return null;
 }
开发者ID:ncuong,项目名称:lifeguard,代码行数:32,代码来源:SignupForm.php

示例6: signup

 /**
  * Signs user up.
  *
  * @return true|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->phone = $this->phone;
         $user->email = $this->email;
         $randLength = mt_rand(6, 9);
         $this->password = Yii::$app->security->generateRandomString($randLength);
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             $profile = new Profile();
             $profile->user_id = $user->id;
             $profile->name = $this->name;
             //если в куках есть id аффилиата, сохраняем его
             $affiliateId = (int) Yii::$app->request->cookies['affiliate'];
             if ($affiliateId > 0 && User::findIdentity($affiliateId)) {
                 $profile->user_affiliate_id = $affiliateId;
             }
             $profile->save();
             return $this->sendRegistrationEmail();
         }
     }
     return null;
 }
开发者ID:eugene-kei,项目名称:yii2-micro-school-crm,代码行数:30,代码来源:SignupForm.php

示例7: reg

 public function reg()
 {
     $user = new User();
     $user->phone = $this->phone;
     $user->email = $this->email;
     $user->status = $this->status;
     $user->setPassword($this->password);
     $user->generateAuthKey();
     if ($this->scenario === 'emailActivation') {
         $user->generateSecretKey();
     }
     $transaction = Yii::$app->db->beginTransaction();
     try {
         if ($user->save()) {
             $modelProfile = new Profile();
             $modelProfile->user_id = $user->id;
             if ($modelProfile->save()) {
                 $transaction->commit();
                 return RbacHelper::assignRole($user->getId()) ? $user : null;
             }
         } else {
             return false;
         }
     } catch (Exception $e) {
         $transaction->rollBack();
     }
 }
开发者ID:baranov-nt,项目名称:some-2,代码行数:27,代码来源:RegForm.php

示例8: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new Admin();
         $user->fname = $this->fname;
         $user->lname = $this->lname;
         $user->contact_no = $this->contact_no;
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->company_name = $this->company_name;
         $user->company_description = $this->company_description;
         $user->shipping_address = $this->shipping_address;
         $user->generateAuthKey();
         $user1 = new User();
         $user1->fname = $this->fname;
         $user1->lname = $this->lname;
         $user1->contact_no = $this->contact_no;
         $user1->username = $this->username;
         $user1->email = $this->email;
         $user1->setPassword($this->password);
         $user1->company_name = $this->company_name;
         $user1->company_description = $this->company_description;
         $user1->shipping_address = $this->shipping_address;
         $user1->generateAuthKey();
         if ($user->save() && $user1->save()) {
             return $user;
             return $user1;
         }
     }
     return null;
 }
开发者ID:pdbangibang,项目名称:apc-softdev-gd121mi122-4,代码行数:37,代码来源:SignupForm.php

示例9: signup

 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->phone = $this->phone;
         $user->setPassword($this->password);
         if (empty($this->username)) {
             $user->username = $this->phone;
         } else {
             $user->username = $this->username;
         }
         if (!empty($this->email)) {
             $user->email = $this->email;
         }
         #$user->generateAuthKey();
         $ret = $user->save();
         if (!$ret) {
             Yii::$app->getSession()->setFlash('error', '系统错误,注册失败。');
             return false;
         }
         return $user;
     }
     $error = array_pop($this->getErrors());
     Yii::$app->getSession()->setFlash('error', $error[0]);
     return false;
 }
开发者ID:johnny618,项目名称:love,代码行数:26,代码来源:SignupForm.php

示例10: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $model = new SignupForm();
         $user->firstname = $this->firstname;
         $user->lastname = $this->lastname;
         $user->clubname = $this->clubname;
         $user->phonenumber = $this->phonenumber;
         $user->mobilenumber = $this->mobilenumber;
         $user->dateofbirth = $this->dateofbirth;
         $user->address = $this->address;
         $user->description = $this->description;
         $model->file = UploadedFile::getInstance($model, 'file');
         if ($model->file) {
             $model->file->saveAs('uploads/' . $model->file->name);
             $user->image = $model->file->name;
         }
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }
开发者ID:praveen-tissera,项目名称:Horsebuzz,代码行数:33,代码来源:SignupForm.php

示例11: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->company_id = $this->company_id;
         $user->first_name = $this->first_name;
         $user->last_name = $this->last_name;
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             $permissionList = $_POST['SignupForm']['permissions'];
             foreach ($permissionList as $value) {
                 $newPermissions = new AuthAssignment();
                 $newPermissions->user_id = $user->id;
                 $newPermissions->item_name = $value;
                 $newPermissions->save();
                 $newPermissions->getErrors();
             }
             return $user;
         }
     }
     return null;
 }
开发者ID:hendrasyp,项目名称:YII2-Setup,代码行数:30,代码来源:SignupForm.php

示例12: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->gender = $this->gender;
         $user->firstname = $this->firstname;
         $user->lastname = $this->lastname;
         $user->username = $this->email;
         $user->email = $this->email;
         $user->birthday = $this->birthday;
         $user->user_role = $this->user_role;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             if ($user->user_role == 'host') {
                 $auth = Yii::$app->authManager;
                 $hostRole = $auth->getRole('host');
                 $auth->assign($hostRole, $user->id);
             } elseif ($user->user_role == 'traveller') {
                 $auth = Yii::$app->authManager;
                 $hostRole = $auth->getRole('traveller');
                 $auth->assign($hostRole, $user->id);
             }
             return $user;
         }
     }
     return null;
 }
开发者ID:Junaid-Farid,项目名称:staylance-new,代码行数:33,代码来源:SignupForm.php

示例13: signup

 /**
  * 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->type = $this->type;
         $user->first_name = $this->first_name;
         $user->last_name = $this->last_name;
         $user->full_name = $this->first_name . " " . $this->last_name;
         $user->age = $this->age;
         $user->gender = $this->gender;
         $user->birthdate = $this->birthdate;
         $user->address = $this->address;
         if ($this->type == 'Student') {
             $user->section_id = $this->section_id;
             $user->level_id = $this->level_id;
         } else {
             $user->section_id = '';
             $user->level_id = '';
         }
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             Yii::$app->session->setFlash('success');
         } else {
             Yii::$app->session->setFlash('failed');
         }
     }
     return null;
 }
开发者ID:kbchong,项目名称:projectwork,代码行数:36,代码来源:SignupForm.php

示例14: actionCreate

 public function actionCreate()
 {
     $model = new User();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             $str = 'abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' . date('yyydmmdhis');
             $potong = str_shuffle($str);
             $random = substr($potong, 3, 12);
             $model->setPassword($random);
             $model->username = $_POST['User']['username'];
             $model->role = $_POST['User']['role'];
             $model->generateAuthKey();
             $content = '
                 <center><img src="http://i.imgur.com/p5lHZXS.png"/></center><br/>
                 <h4 align="center">Badan Pengawas Tenaga Nuklir  ' . date('Y') . '</h4>
                 <hr/>
                 <p>Yth ' . $model->username . ',<br/>  
                 Dengan ini kami sampaikan akun telah terdaftar untuk masuk ke Sistem Aplikasi Perjalanan Dinas – BAPETEN, sebagai berikut:<br/> 
                 Username : ' . $model->username . ' <br/>
                 Password :<b>' . $random . '</b><br/>
                 Mohon lakukan penggantian password Anda setelah melakukan login.\\n
                 Terima Kasih. <hr/>
                 <h5 align="center">Subbag Perjalanan Dinas Biro Umum BAPETEN  ' . date('Y') . '</h5><br/>';
             Yii::$app->mailer->compose("@common/mail/layouts/html", ["content" => $content])->setTo($_POST['User']['email'])->setFrom([$_POST['User']['email'] => $model->username])->setSubject('Ubah Kata Sandi')->setTextBody($random)->send();
             $model->save();
             return $this->redirect(['index']);
         } else {
             var_dump($model->errors);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:ilhammalik,项目名称:yii2-advanced-beta,代码行数:33,代码来源:UserController.php

示例15: signup

 /**
  * 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->nama = $this->nama;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->tanggal_lahir = $this->tanggal_lahir;
         $user->fakultas = $this->fakultas;
         $user->jurusan = $this->jurusan;
         $user->angkatan = $this->angkatan;
         $user->pekerjaan = $this->pekerjaan;
         $user->alamat_rumah = $this->alamat_rumah;
         $user->alamat_domilisi = $this->alamat_domilisi;
         $user->no_hp = $this->no_hp;
         $user->id_line = $this->id_line;
         $user->foto = 'uploads/' . $this->foto;
         $user->generateAuthKey();
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }
开发者ID:andrikurniawan,项目名称:immmweb,代码行数:30,代码来源:SignupForm.php


注:本文中的common\models\User::setPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。