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


PHP User::register方法代码示例

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


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

示例1: register

 /**
  * Registers a new user account.
  * @return bool
  */
 public function register()
 {
     if (!$this->validate()) {
         return false;
     }
     $this->user->setAttributes(['email' => $this->email, 'username' => $this->username, 'password' => $this->password]);
     return $this->user->register();
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:12,代码来源:RegistrationForm.php

示例2: actionCreate

 /**
  * Creates a new SocialServiceManager model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new SocialServiceManager();
     if ($model->load(Yii::$app->request->post())) {
         $person = new Person();
         $person->name = $model->name;
         $person->lastname = $model->last_name;
         $person->phone = $model->phone;
         $person->save(false);
         $user = new User();
         $user->username = $model->username;
         $user->password = $model->password;
         $user->email = $model->email;
         $user->person_id = $person->id;
         $user->scenario = 'register';
         if ($user->validate(['username', 'password'])) {
             $user->register();
             $model->user_id = $user->id;
             $model->save(false);
             //assign the role to the user
             $authManager = Yii::$app->getAuthManager();
             $socialServiceMRole = $authManager->getRole('socialServiceManager');
             $authManager->assign($socialServiceMRole, $user->id);
             //set the success message
             Yii::$app->getSession()->setFlash('success', 'Usuario creado con éxito');
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             $model->addErrors($user->errors);
         }
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:RomarioLopezC,项目名称:RobotSS,代码行数:37,代码来源:SocialServiceManagerController.php

示例3: testRegister

 public function testRegister()
 {
     $this->specify('user should be registered', function () {
         $user = new User(['scenario' => 'register']);
         $user->username = 'tester';
         $user->email = 'tester@example.com';
         $user->password = 'tester';
         verify($user->register())->true();
         verify($user->username)->equals('tester');
         verify($user->email)->equals('tester@example.com');
         verify(Yii::$app->getSecurity()->validatePassword('tester', $user->password_hash))->true();
     });
     $this->specify('profile should be created after registration', function () {
         $user = new User(['scenario' => 'register']);
         $user->username = 'john_doe';
         $user->email = 'john_doe@example.com';
         $user->password = 'qwerty';
         verify($user->register())->true();
         verify($user->profile->gravatar_email)->equals('john_doe@example.com');
     });
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:21,代码来源:UserTest.php

示例4: register

 public function register()
 {
     return parent::register();
     // do your magic
 }
开发者ID:kd-brinex,项目名称:paruram,代码行数:5,代码来源:User.php


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