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


PHP User::className方法代码示例

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


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

示例1: actionConnect

 public function actionConnect($account_id)
 {
     //var_dump("connect");die;
     $account = $this->finder->findAccountById($account_id);
     if ($account === null || $account->getIsConnected()) {
         throw new NotFoundHttpException();
     }
     /** @var User $user */
     $user = \Yii::createObject(['class' => User::className(), 'scenario' => 'connect']);
     if (\Yii::$app->request->get("provider") == 'kd') {
         $data = array();
         $data['User'] = array();
         $data['User']['username'] = \Yii::$app->request->get("username");
         $data['User']['email'] = \Yii::$app->request->get("email");
     } else {
         $data = \Yii::$app->request->post();
     }
     if ($user->load($data) && $user->create()) {
         $account->user_id = $user->id;
         $account->save(false);
         \Yii::$app->user->login($user, $this->module->rememberFor);
         return $this->goBack();
     }
     return $this->render('connect', ['model' => $user, 'account' => $account]);
 }
开发者ID:kd-brinex,项目名称:kd,代码行数:25,代码来源:RegistrationController.php

示例2: actionCreate

 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'index' page.
  *
  * @return mixed
  */
 public function actionCreate()
 {
     /** @var User $user */
     $user = Yii::createObject(['class' => User::className(), 'scenario' => 'create']);
     $this->performAjaxValidation($user);
     if ($user->load(Yii::$app->request->post()) && $user->create()) {
         Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been created'));
         return $this->redirect(['update', 'id' => $user->id]);
     }
     return $this->render('create', ['user' => $user]);
 }
开发者ID:ketuker,项目名称:oil-palm-cultivation-thesis,代码行数:17,代码来源:AdminController.php

示例3: testLogin

 /**
  * Tests login method.
  */
 public function testLogin()
 {
     $user = \Yii::createObject(User::className());
     test::double(Finder::className(), ['findUserByUsernameOrEmail' => $user]);
     $form = Yii::createObject(LoginForm::className());
     $form->beforeValidate();
     test::double($form, ['validate' => false]);
     verify($form->login())->false();
     test::double($form, ['validate' => true]);
     test::double(\yii\web\User::className(), ['login' => false]);
     verify($form->login())->false();
     test::double(\yii\web\User::className(), ['login' => true]);
     verify($form->login())->true();
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:17,代码来源:LoginFormTest.php

示例4: actionIndex

 /**
  * This command creates new user account. If password is not set, this command will generate new 8-char password.
  * After saving user to database, this command uses mailer component to send credentials (username and password) to
  * user via email.
  *
  * @param string      $email    Email address
  * @param string      $username Username
  * @param null|string $password Password (if null it will be generated automatically)
  */
 public function actionIndex($email, $username, $password = null)
 {
     $user = Yii::createObject(['class' => User::className(), 'scenario' => 'create', 'email' => $email, 'username' => $username, 'password' => $password]);
     if ($user->create()) {
         $this->stdout(Yii::t('user', 'User has been created') . "!\n", Console::FG_GREEN);
     } else {
         $this->stdout(Yii::t('user', 'Please fix following errors:') . "\n", Console::FG_RED);
         foreach ($user->errors as $errors) {
             foreach ($errors as $error) {
                 $this->stdout(' - ' . $error . "\n", Console::FG_RED);
             }
         }
     }
 }
开发者ID:TheManagers,项目名称:yii2-user,代码行数:23,代码来源:CreateController.php

示例5: frontendRegister

 /**
  * the register customer will be added  'customer' role
  */
 public static function frontendRegister()
 {
     Event::on(User::className(), User::USER_REGISTER_DONE, function ($event) {
         /** @var \yii\base\ModelEvent $event */
         $user = $event->sender;
         $auth = new DbManager();
         $auth->init();
         $role = $auth->getRole('Customer');
         if (!$role) {
             $role = $auth->createRole('Customer');
             $auth->add($role);
         }
         $auth->assign($role, $user->id);
     });
 }
开发者ID:shuangjie,项目名称:galaxy,代码行数:18,代码来源:UserEvent.php

示例6: register

 /**
  * Registers a new user account. If registration was successful it will set flash message.
  *
  * @return bool
  */
 public function register()
 {
     if (!$this->validate()) {
         return false;
     }
     /** @var User $user */
     $user = Yii::createObject(User::className());
     $user->setScenario('register');
     $this->loadAttributes($user);
     if (!$user->register()) {
         return false;
     }
     Yii::$app->session->setFlash('info', Yii::t('user', 'Your account has been created and a message with further instructions has been sent to your email'));
     return true;
 }
开发者ID:damasco,项目名称:yii2-user,代码行数:20,代码来源:RegistrationForm.php

示例7: actionConnect

 /**
  * Displays page where user can create new account that will be connected to social account.
  * @param  integer $account_id
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionConnect($account_id)
 {
     $account = $this->finder->findAccountById($account_id);
     if ($account === null || $account->getIsConnected()) {
         throw new NotFoundHttpException();
     }
     /** @var User $user */
     $user = \Yii::createObject(['class' => User::className(), 'scenario' => 'connect']);
     if ($user->load(\Yii::$app->request->post()) && $user->create()) {
         $account->link('user', $user);
         \Yii::$app->user->login($user, $this->module->rememberFor);
         return $this->goBack();
     }
     return $this->render('connect', ['model' => $user, 'account' => $account]);
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:21,代码来源:RegistrationController.php

示例8: actionConnect

 /**
  * Displays page where user can create new account that will be connected to social account.
  *
  * @param string $code
  *
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionConnect($code)
 {
     $account = $this->finder->findAccount()->byCode($code)->one();
     if ($account === null || $account->getIsConnected()) {
         throw new NotFoundHttpException();
     }
     /** @var User $user */
     $user = Yii::createObject(['class' => User::className(), 'scenario' => 'connect', 'username' => $account->username, 'email' => $account->email]);
     if ($user->load(Yii::$app->request->post()) && $user->create()) {
         $account->connect($user);
         Yii::$app->user->login($user, $this->module->rememberFor);
         return $this->goBack();
     }
     return $this->render('connect', ['model' => $user, 'account' => $account]);
 }
开发者ID:ketuker,项目名称:oil-palm-cultivation-thesis,代码行数:23,代码来源:RegistrationController.php

示例9: up

 public function up()
 {
     if (isset($_SERVER['TRAVIS']) || isset($_SERVER['PWD']) && strpos($_SERVER['PWD'], '/tests/')) {
         return null;
     }
     $userName = 'webmaster';
     $tableName = \dektrium\user\models\User::tableName();
     $query = 'SELECT COUNT(*) FROM ' . $tableName . ' WHERE `username`=:username';
     $count = \Yii::$app->db->createCommand($query, [':username' => $userName])->queryScalar();
     if ($count > 0) {
         return null;
     }
     $user = \Yii::createObject(['class' => \dektrium\user\models\User::className(), 'scenario' => 'create', 'username' => $userName, 'password' => $userName, 'email' => $userName . '@yii2enterprise.dev']);
     return $user->create();
 }
开发者ID:sibds,项目名称:yii2-enterprise,代码行数:15,代码来源:m160219_091156_createUser.php

示例10: up

 public function up()
 {
     $user = Yii::createObject(['class' => User::className(), 'scenario' => 'create', 'email' => 'admin@example.com', 'username' => 'admin', 'password' => '123456']);
     if ($user->create()) {
         echo Yii::t('user', 'User has been created') . "\n";
         echo 'Login: admin' . "\n";
         echo 'Password: 123456' . "\n";
     } else {
         echo Yii::t('user', 'Please fix following errors:') . "\n";
         foreach ($user->errors as $errors) {
             foreach ($errors as $error) {
                 echo ' - ' . $error . "\n";
             }
         }
     }
     if (!empty($user->errors)) {
         return false;
     }
 }
开发者ID:chabberwock,项目名称:halo-dev,代码行数:19,代码来源:m151209_032228_default_admin.php

示例11: function

<?php

/**
 * @author Eugene Terentev <eugene@terentev.net>
 */
\yii\base\Event::on(\yii\web\User::className(), \yii\web\User::EVENT_AFTER_LOGIN, function ($event) {
    //同步登陆ucenter
    \common\util\UcenterUtil::syncLogin($event);
    //记录前台登陆日志
    $user = $event->identity;
    $model = new \common\models\UserLoginLog();
    $model->user_id = $user->id;
    $model->username = $user->username;
    $model->login_ip = \Yii::$app->request->getUserIP();
    $model->login_time = time();
    $model->os = \Yii::$app->request->getUserAgent();
    $model->category = __METHOD__;
    $model->save(false);
});
//同步退出ucenter
\yii\base\Event::on(\yii\web\User::className(), \yii\web\User::EVENT_AFTER_LOGOUT, function ($event) {
    \common\util\UcenterUtil::logout();
});
//同步删除ucenter的用户
\yii\base\Event::on(\dektrium\user\models\User::className(), \dektrium\user\models\User::EVENT_AFTER_DELETE, function ($event) {
    $ucUser = \common\util\UcenterUtil::getUser($event->sender->username);
    \common\util\UcenterUtil::ucUserDelete($ucUser[0]);
    //删除discuz中common_member中用户信息
    $dzHelper = new \common\util\DzHelper();
    $dzHelper->deleteDzUserByUsername($ucUser[1]);
});
开发者ID:buuug7,项目名称:game4039,代码行数:31,代码来源:bootstrap.php

示例12:

$page->updateEmail('wrong', 'new_email@example.com');
$I->see('Current password is not valid');
$page->updateEmail('qwerty', 'new_email@example.com');
$I->see('Before your email will be changed we need you to confirm your new email address');
$I->seeRecord(User::className(), ['id' => $user->id, 'email' => 'user@example.com', 'unconfirmed_email' => 'new_email@example.com']);
$user = $I->grabRecord(User::className(), ['id' => $user->id]);
$token = $I->grabRecord(Token::className(), ['user_id' => $user->id, 'type' => Token::TYPE_CONFIRMATION]);
$I->seeInEmail(Html::encode($token->getUrl()));
$I->seeInEmailRecipients($user->unconfirmed_email);
Yii::$app->getUser()->logout();
$I->amGoingTo('login with new email');
$loginPage = LoginPage::openBy($I);
$loginPage->login('new_email@example.com', 'qwerty');
$I->see('Invalid login or password');
$user->attemptConfirmation($token->code);
$loginPage = LoginPage::openBy($I);
$loginPage->login('user@example.com', 'qwerty');
$I->see('Invalid login or password');
$loginPage->login('new_email@example.com', 'qwerty');
$I->see('Logout');
$user = $I->grabRecord(User::className(), ['id' => $user->id]);
$I->seeRecord(User::className(), ['id' => 1, 'email' => 'new_email@example.com', 'unconfirmed_email' => null]);
// try to reset email change
$page = EmailSettingsPage::openBy($I);
$page->updateEmail('qwerty', 'user@example.com');
$I->see('Before your email will be changed we need you to confirm your new email address');
$I->seeRecord(User::className(), ['id' => 1, 'email' => 'new_email@example.com', 'unconfirmed_email' => 'user@example.com']);
$page->updateEmail('qwerty', 'new_email@example.com');
$I->see('Email change has been cancelled');
$I->seeRecord(User::className(), ['id' => 1, 'email' => 'new_email@example.com', 'unconfirmed_email' => null]);
开发者ID:ilyar,项目名称:dektrium-yii2-user,代码行数:30,代码来源:EmailSettingsCept.php

示例13: fetchUser

 /**
  * Tries to find user or create a new one.
  *
  * @param ClientInterface $client
  *
  * @return User|bool False when can't create user.
  */
 protected static function fetchUser(ClientInterface $client)
 {
     $user = static::getFinder()->findUserByEmail($client->getEmail());
     if (null !== $user) {
         return $user;
     }
     $user = Yii::createObject(['class' => User::className(), 'scenario' => 'connect', 'username' => $client->getUsername(), 'email' => $client->getEmail()]);
     if (!$user->validate(['email'])) {
         return false;
     }
     if (!$user->validate(['username'])) {
         $user->username = null;
     }
     return $user->create() ? $user : false;
 }
开发者ID:GrowlMediaLtd,项目名称:yii2-user,代码行数:22,代码来源:Account.php

示例14: getModifiedby

 public function getModifiedby()
 {
     return $this->hasOne(User::className(), ['id' => 'modified_by'])->from(User::tableName() . ' AS modifiedby');
 }
开发者ID:quato,项目名称:yii2-articles,代码行数:4,代码来源:Items.php

示例15: FunctionalTester

use yii\helpers\Html;
use yii\helpers\Url;
use dektrium\user\models\User;
use dektrium\user\models\Token;
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that password recovery works');
$page = RecoveryPage::openBy($I);
$I->amGoingTo('try to request recovery token for unconfirmed account');
$user = $I->getFixture('user')->getModel('unconfirmed');
$page->recover($user->email);
$I->see('You need to confirm your email address');
$I->amGoingTo('try to request recovery token');
$user = $I->getFixture('user')->getModel('user');
$page->recover($user->email);
$I->see('You will receive an email with instructions on how to reset your password in a few minutes.');
$user = $I->grabRecord(User::className(), ['email' => $user->email]);
$token = $I->grabRecord(Token::className(), ['user_id' => $user->id, 'type' => Token::TYPE_RECOVERY]);
$I->seeInEmail(Html::encode($token->getUrl()));
$I->seeInEmailRecipients($user->email);
$I->amGoingTo('reset password with invalid token');
$user = $I->getFixture('user')->getModel('user_with_expired_recovery_token');
$token = $I->grabRecord(Token::className(), ['user_id' => $user->id, 'type' => Token::TYPE_RECOVERY]);
$I->amOnPage(Url::toRoute(['/user/recovery/reset', 'id' => $user->id, 'code' => $token->code]));
$I->see('Recovery link is invalid or out-of-date. Please try requesting a new one.');
$I->amGoingTo('reset password');
$user = $I->getFixture('user')->getModel('user_with_recovery_token');
$token = $I->grabRecord(Token::className(), ['user_id' => $user->id, 'type' => Token::TYPE_RECOVERY]);
$I->amOnPage(Url::toRoute(['/user/recovery/reset', 'id' => $user->id, 'code' => $token->code]));
$I->fillField('#recovery-form-password', 'newpass');
$I->click('Finish');
$I->see('Your password has been changed successfully.');
开发者ID:kongoon,项目名称:yii2-user,代码行数:31,代码来源:RecoveryCept.php


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