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


PHP User::generatePasswordResetToken方法代码示例

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


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

示例1: generateToken

 public function generateToken()
 {
     $mobile = $this->_session['passwordResetMobile'];
     $this->_user = User::findByMobile($mobile);
     if (!User::isPasswordResetTokenValid($this->_user->password_reset_token)) {
         $this->_user->generatePasswordResetToken();
     }
     return $this->_user->save(false);
 }
开发者ID:daixianceng,项目名称:xiaoego.com,代码行数:9,代码来源:PasswordResetVerifyForm.php

示例2: actionInit

 public function actionInit()
 {
     //$auth = Yii::$app->authManager;
     $user = new User();
     $user->username = "hoangl";
     $user->email = "hoangl@viettel.com.vn";
     $user->status = 10;
     $user->setPassword("abc@1234");
     $user->generatePasswordResetToken();
     $user->generateAuthKey();
     $user->save();
 }
开发者ID:hoangl,项目名称:AwsProject,代码行数:12,代码来源:RbacController.php

示例3: actionCreate

 /**
  * 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->setScenario('create_user');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $model->generatePasswordResetToken();
         $model->save(false);
         return $this->redirect(['view', 'id' => $model->id]);
     }
     $model->status = User::STATUS_ACTIVE;
     $model->group = User::GROUP_READER;
     return $this->render('create', ['model' => $model]);
 }
开发者ID:specialnote,项目名称:myYii,代码行数:18,代码来源:UserController.php

示例4: insert

 public function insert(UserDto $userDto)
 {
     $user = new User();
     $qUserDto = new UserDto();
     $qUserDto->setScenario('admin-query');
     if ($user->load(['User' => ArrayHelper::toArray($userDto)])) {
         $user->setPassword($userDto->password);
         $user->generateAuthKey();
         $user->generatePasswordResetToken();
         $user->insert();
         return ArrayHelper::toArray($user, ['common\\models\\User' => $qUserDto->activeAttributes()]);
     } else {
         return [];
     }
 }
开发者ID:xiaomige,项目名称:giishop,代码行数:15,代码来源:UserServiceImpl.php

示例5: successCallback

 public function successCallback($client)
 {
     $attributes = $client->getUserAttributes();
     /** @var Auth $auth */
     $auth = Auth::find()->where(['source' => $client->getId(), 'source_id' => $attributes['id']])->one();
     $attributes['login'] = $attributes['login'] ? $attributes['login'] : $attributes['last_name'] . ' ' . $attributes['first_name'];
     if (Yii::$app->user->isGuest) {
         if ($auth) {
             // login
             $user = $auth->user;
             $user->username = $attributes['login'];
             $user->photo = $attributes['photo'];
             $user->save();
             Yii::$app->user->login($user);
         } else {
             // signup
             if (isset($attributes['email']) && isset($attributes['username']) && User::find()->where(['email' => $attributes['email']])->exists()) {
                 Yii::$app->getSession()->setFlash('error', [Yii::t('app', "User with the same email as in {client} account already exists but isn't linked to it. Login using email first to link it.", ['client' => $client->getTitle()])]);
             } else {
                 $user = new User(['username' => $attributes['login'], 'email' => $attributes['email'], 'first_name' => $attributes['first_name'], 'last_name' => $attributes['last_name'], 'sex' => $attributes['sex'], 'photo' => $attributes['photo'], 'password' => Yii::$app->security->generateRandomString(6)]);
                 $user->generateAuthKey();
                 $user->generatePasswordResetToken();
                 $transaction = $user->getDb()->beginTransaction();
                 if ($user->save()) {
                     $auth = new Auth(['user_id' => $user->id, 'source' => $client->getId(), 'source_id' => (string) $attributes['id']]);
                     if ($auth->save()) {
                         $transaction->commit();
                         Yii::$app->user->login($user);
                     } else {
                         print_r($auth->getErrors());
                     }
                 } else {
                     print_r($user->getErrors());
                 }
             }
         }
     } else {
         // user already logged in
         if (!$auth) {
             // add auth provider
             $auth = new Auth(['user_id' => Yii::$app->user->id, 'source' => $client->getId(), 'source_id' => $attributes['id']]);
             $auth->save();
         }
     }
 }
开发者ID:chameleon82,项目名称:yiindo,代码行数:45,代码来源:SiteController.php

示例6: safeUp

 public function safeUp()
 {
     $this->alterColumn('{{user}}', 'email', 'drop not null');
     $auth = Yii::$app->authManager;
     // создание разрешения на все
     $permission = $auth->createPermission($this->permissionName);
     $permission->description = 'Доступ ко всем функциям системы';
     $auth->add($permission);
     // создание роли супер администратора
     $role = $auth->createRole($this->roleName);
     $role->description = 'Супер администратор';
     $auth->add($role);
     $auth->addChild($role, $permission);
     $user = new common\models\User();
     $user->username = $this->userLogin;
     $user->setPassword($this->userPassword);
     $user->generateAuthKey();
     $user->generatePasswordResetToken();
     $user->save();
     $auth->assign($role, $user->id);
 }
开发者ID:podvincev-n,项目名称:yii2-module-rbac,代码行数:21,代码来源:m150101_000004_rbac_superadmin_role.php

示例7: loadAttributes

 /**
  * Loads attributes to the user model. You should override this method if you are going to add new fields to the
  * registration form. You can read more in special guide.
  *
  * By default this method set all attributes of this model to the attributes of User model, so you should properly
  * configure safe attributes of your User model.
  *
  * @param User $user
  */
 protected function loadAttributes(\common\models\User $user)
 {
     $user->setAttributes($this->attributes);
     $user->generatePasswordResetToken();
     $user->is_provider = 0;
     $user->registered_by();
     $user->generateInviteHash();
     $user->generatePhoneVerificationHash();
     $user->generateRoleCode();
     $user->created_at = time();
     $user->updated_at = time();
     $user->status = 20;
 }
开发者ID:bokko79,项目名称:servicemapp,代码行数:22,代码来源:RegistrationUserForm.php

示例8: onAuthSuccess

 /**
  * Logs in a user.
  *
  * @return mixed
  */
 public function onAuthSuccess($client)
 {
     $data = Yii::$app->getRequest()->getQueryParam("auth_key");
     if (!$this->getInviteKey($data)) {
         Yii::$app->session->setFlash("error", "Not have permision");
         return $this->redirect(["/"]);
     }
     $attributes = $client->getUserAttributes();
     /** @var Auth $auth */
     $auth = Auth::find()->where(['source' => $client->getId(), 'source_id' => $attributes['id']])->one();
     if (Yii::$app->user->isGuest) {
         if ($auth) {
             $user = $auth->user;
             Yii::$app->user->login($user);
             return $this->redirect("site/user");
         } else {
             // signup
             $email = isset($attributes['email']) ? $attributes['email'] : "";
             $invite = Invitation::find()->where(['send_key' => $data, 'email' => $email])->one();
             if (isset($attributes['name']) && !empty($invite)) {
                 $password = Yii::$app->security->generateRandomString(8);
                 if (!isset($attributes['email'])) {
                     $attributes['email'] = '';
                 }
                 $fileName = null;
                 $picturePath = null;
                 if (isset($attributes['picture']) && isset($attributes['picture']['data']) && isset($attributes['picture']['data']['url'])) {
                     $picturePath = $attributes['picture']['data']['url'];
                 } elseif (isset($attributes['profile_image_url'])) {
                     $picturePath = $attributes['profile_image_url'];
                 }
                 // COMMENT: ADD PHOTO FROM FACEBOOK DATA TO DATABASE method file_put_contents - http://php.net/manual/ru/function.file-put-contents.php
                 if ($picturePath) {
                     $photoFile = file_get_contents($picturePath);
                     $security = new \yii\base\Security();
                     $fileName = $security->generateRandomString() . '.jpg';
                     $directory = Yii::getAlias('@frontend/web/' . Yii::$app->params['user-photos-directory']);
                     file_put_contents($directory . DIRECTORY_SEPARATOR . $fileName, $photoFile);
                 }
                 $user = new User(['username' => $attributes['name'], 'email' => $attributes['email'], 'password' => $password, 'image' => $fileName, 'sex' => !empty($attributes['gender']) ? $attributes['gender'] : "", 'country' => !empty($attributes['hometown']['name']) ? $attributes['hometown']['name'] : "", 'created_at' => time(), 'updated_at' => time()]);
                 $user->generateAuthKey();
                 $user->generatePasswordResetToken();
                 $transaction = $user->getDb()->beginTransaction();
                 if ($user->save()) {
                     $auth = new Auth(['user_id' => $user->id, 'source' => $client->getId(), 'source_id' => (string) $attributes['id'], 'email' => $attributes['email']]);
                     $invite->status = Invitation::STATUS_SIGNUP;
                     $invite->save();
                     if ($auth->save()) {
                         $transaction->commit();
                         Yii::$app->user->login($user);
                         return $this->redirect(["/"]);
                     } else {
                         print_r($auth->getErrors());
                     }
                 } else {
                     print_r($user->getErrors());
                 }
             } else {
                 Yii::$app->session->setFlash("error", "Email not equals");
                 return $this->redirect(['site/invite', 'auth_key' => $data]);
             }
         }
     } else {
         // user already logged in
         if (!$auth) {
             // add auth provider
             $auth = new Auth(['user_id' => Yii::$app->user->id, 'source' => $client->getId(), 'source_id' => $attributes['id']]);
             $auth->save();
         }
     }
 }
开发者ID:bolom009,项目名称:testwork_vdo,代码行数:76,代码来源:SiteController.php


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