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


PHP User::afterSignup方法代码示例

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


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

示例1: 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->save();
         $user->afterSignup();
         return $user;
     }
     return null;
 }
开发者ID:dellirom,项目名称:yii2-starter-kit,代码行数:18,代码来源:SignupForm.php

示例2: 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->status = Yii::$app->keyStorage->get('frontend.email-confirm') ? User::STATUS_INACTIVE : User::STATUS_ACTIVE;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->save();
         $user->afterSignup();
         return $user;
     }
     return null;
 }
开发者ID:beaten-sect0r,项目名称:yii2-core,代码行数:20,代码来源:SignupForm.php

示例3: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $shouldBeActivated = $this->shouldBeActivated();
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->is_activated = !$shouldBeActivated;
         $user->setPassword($this->password);
         $user->save();
         $user->afterSignup();
         if ($shouldBeActivated) {
             $token = UserToken::create($user->id, UserToken::TYPE_ACTIVATION, Time::SECONDS_IN_A_DAY);
             Yii::$app->commandBus->handle(new SendEmailCommand(['subject' => Yii::t('frontend', 'Activation email'), 'view' => 'activation', 'params' => ['url' => Url::to(['/user/sign-in/activation', 'token' => $token->token], true)]]));
         }
         return $user;
     }
     return null;
 }
开发者ID:icron,项目名称:yii2-starter-kit,代码行数:24,代码来源: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->save();
         $user->afterSignup();
         $auth = Yii::$app->authManager;
         $auth->revokeAll($user->getId());
         if ($this->roles && is_array($this->roles)) {
             foreach ($this->roles as $role) {
                 $auth->assign($auth->getRole($role), $user->getId());
             }
         }
         return $user;
     }
     return null;
 }
开发者ID:Sywooch,项目名称:AVSProduct,代码行数:25,代码来源:SignupForm.php

示例5: successOAuthCallback

 /**
  * @param $client \yii\authclient\BaseClient
  * @return bool
  * @throws Exception
  */
 public function successOAuthCallback($client)
 {
     // use BaseClient::normalizeUserAttributeMap to provide consistency for user attribute`s names
     $attributes = $client->getUserAttributes();
     $user = User::find()->where(['oauth_client' => $client->getName(), 'oauth_client_user_id' => ArrayHelper::getValue($attributes, 'id')])->one();
     if (!$user) {
         $user = new User();
         $user->scenario = 'oauth_create';
         $user->username = ArrayHelper::getValue($attributes, 'login');
         $user->email = ArrayHelper::getValue($attributes, 'email');
         $user->oauth_client = $client->getName();
         $user->oauth_client_user_id = ArrayHelper::getValue($attributes, 'id');
         $password = Yii::$app->security->generateRandomString(8);
         $user->setPassword($password);
         if ($user->save()) {
             $user->afterSignup();
             $sentSuccess = Yii::$app->commandBus->handle(new SendEmailCommand(['view' => 'oauth_welcome', 'params' => ['user' => $user, 'password' => $password], 'subject' => Yii::t('frontend', '{app-name} | Your login information', ['app-name' => Yii::$app->name]), 'to' => $user->email]));
             if ($sentSuccess) {
                 Yii::$app->session->setFlash('alert', ['options' => ['class' => 'alert-success'], 'body' => Yii::t('frontend', 'Welcome to {app-name}. Email with your login information was sent to your email.', ['app-name' => Yii::$app->name])]);
             }
         } else {
             // We already have a user with this email. Do what you want in such case
             if (User::find()->where(['email' => $user->email])->count()) {
                 Yii::$app->session->setFlash('alert', ['options' => ['class' => 'alert-danger'], 'body' => Yii::t('frontend', 'We already have a user with email {email}', ['email' => $user->email])]);
             } else {
                 Yii::$app->session->setFlash('alert', ['options' => ['class' => 'alert-danger'], 'body' => Yii::t('frontend', 'Error while oauth process.')]);
             }
         }
     }
     if (Yii::$app->user->login($user, 3600 * 24 * 30)) {
         return true;
     } else {
         throw new Exception('OAuth error');
     }
 }
开发者ID:rzrio,项目名称:enterprise-portal,代码行数:40,代码来源:SignInController.php


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