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


PHP User::findByUsername方法代码示例

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


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

示例1: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByUsername($this->username);
     }
     return $this->_user;
 }
开发者ID:pdbangibang,项目名称:apc-softdev-gd121mi122-4,代码行数:12,代码来源:LoginForm.php

示例2: actionIndex

 /**
  *   上传头像
  *   图片上传成功后做标记,渲染裁剪功能,裁剪后坐标传送给Headcut,Headcut进行裁剪,保存图片,标记。
  */
 public function actionIndex()
 {
     $accessKey = 'l5Y69nZUNTSeeqJx1LqCJP1KuLWIGU_3JVZXLzN-';
     $secretKey = '6-4HOEBkNlJpo_TuFrM9W8ZEjytRZAYjuiG0F8Df';
     $auth = new Auth($accessKey, $secretKey);
     $bucketMgr = new BucketManager($auth);
     $bucket = 'colfans-uploads-public';
     $key = 'fun.jpg';
     list($ret, $err) = $bucketMgr->stat($bucket, $key);
     echo "\n====> stat result: \n";
     if ($err !== null) {
         var_dump($err);
     } else {
         var_dump($ret);
     }
     if (!empty($_FILES['headpic'])) {
         $user = User::findByUsername(Yii::$app->user->identity->username);
         $image = UploadedFile::getInstanceByName('headpic');
         $imageName = $user->id . '_' . time() . '.' . $image->getExtension();
         if ($image->saveAs('uploads/head/' . $imageName)) {
             // file is uploaded successfully
             echo 'yes';
             die;
         } else {
             echo 'no';
             die;
         }
     } else {
         return $this->render('headupload', ['title' => '个人资料', 'category' => '账号管理', 'subcate' => '个人资料']);
     }
 }
开发者ID:BonVa,项目名称:colfans,代码行数:35,代码来源:UploadController.php

示例3: actionIndex

 /**
  * Lists all Posts models.
  * @return mixed
  */
 public function actionIndex($username)
 {
     $userid = \common\models\User::findByUsername($username)->id;
     $ingredients = Cocktails::getAvaliableIngredients();
     $userIngredients = Cocktails::getUserIngredients();
     return $this->render('index', ['ingredients' => $ingredients, 'userIngredients' => $userIngredients, 'username' => $username]);
 }
开发者ID:vladimirgolovanov,项目名称:purrfect-awesome-friends-feed-decorator,代码行数:11,代码来源:CocktailsController.php

示例4: actionView

 public function actionView($username)
 {
     if (($model = User::findByUsername($username)) === null) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     return $this->render('index', ['model' => $model]);
 }
开发者ID:grischuk-sasha,项目名称:friend,代码行数:7,代码来源:ProfileController.php

示例5: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = User::findByUsername($this->username);
     }
     return $this->_user;
 }
开发者ID:kvazarum,项目名称:prereg,代码行数:12,代码来源:LoginForm.php

示例6: actionLogin

 public function actionLogin()
 {
     $result = false;
     $token = '';
     $accessToken = Yii::$app->request->get('access_token');
     if ($accessToken) {
         if (User::findOne(['access_token' => $accessToken])) {
             $result = true;
         }
     } elseif (Yii::$app->request->post('username') && Yii::$app->request->post('password')) {
         $user = User::findByUsername(Yii::$app->request->post('username'));
         if ($user && $user->validatePassword(Yii::$app->request->post('password'))) {
             if ($user->access_token) {
                 $token = $user->access_token;
             } else {
                 $token = hash('sha256', Yii::$app->request->get('username'));
                 Yii::$app->db->createCommand()->update("user", ['access_token' => $token], 'id = ' . $user->id)->execute();
             }
             $result = true;
         }
     }
     if ($result) {
         return ['result' => 'success', 'access_token' => $token];
     } else {
         return ['result' => 'failed'];
     }
 }
开发者ID:laojiu,项目名称:yii2-advanced-funson86,代码行数:27,代码来源:UserController.php

示例7: actionAdduser

 /**
  * Lists all Opduser models.
  * @return mixed
  */
 public function actionAdduser()
 {
     //$request = Yii::$app->request;
     //if ($request->isAjax) { /* ตรวจสอบว่าเป็น ajax */ }
     //if ($request->isGet)  { echo "Is Get"; }
     //if ($request->isPost) { echo "Is Post"; }
     //if ($request->isPut)  { /* ตรวจสอบว่าเป็น PUT */ }
     $username = Yii::$app->request->get('username');
     $email = Yii::$app->request->get('email');
     $password = Yii::$app->request->get('passweb');
     //return $username;
     if (!User::findByUsername($username)) {
         $user = new User();
         $user->username = $username;
         $user->email = $email;
         $user->setPassword($password);
         $user->generateAuthKey();
         $user->status = User::STATUS_ACTIVE;
         if ($user->save()) {
             Yii::$app->session->setFlash('success', 'Successes');
             $this->redirect(\Yii::$app->urlManager->createUrl("opduser/index"));
             //return 'successes';
         } else {
             Yii::$app->session->setFlash('error', 'failed');
             $this->redirect(\Yii::$app->urlManager->createUrl("opduser/index"));
             //return 'failed';
         }
     }
     return 'aleadyexists';
 }
开发者ID:poykub,项目名称:wph,代码行数:34,代码来源:OpduserController.php

示例8: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = User::findByUsername($this->nombreDeUsuario);
     }
     return $this->_user;
 }
开发者ID:jose122946,项目名称:biomedica,代码行数:12,代码来源:LoginForm.php

示例9: 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->login = $this->username ?: $this->email;
         $user->email = $this->email;
         $user->password = $this->password;
         $seller = User::findByUsername($this->seller ?: 'ahnames');
         if (!$seller->id) {
             throw new InvalidParamException('wrong seller given');
         }
         $user->seller_id = $seller->id;
         //$user->setPassword($this->password);
         //$user->generateAuthKey();
         $user->save();
         $user = User::findByUsername($user->login);
         if (!$user) {
             throw new IntegrityException('failed create user');
         }
         $contact = Contact::findOne($user->id);
         $contact->load([$contact->formName() => $this->getAttributes()]);
         $contact->save();
         return $user;
     }
     return null;
 }
开发者ID:hiqdev,项目名称:hi3a,代码行数:31,代码来源:SignupForm.php

示例10: actionIndex

 public function actionIndex($username)
 {
     $userid = \common\models\User::findByUsername($username)->id;
     $data = Wishlist::getWishlistData($userid);
     if ($userid) {
         return $this->render('wishlist', ['data' => $data, 'username' => $username]);
     }
 }
开发者ID:vladimirgolovanov,项目名称:purrfect-awesome-friends-feed-decorator,代码行数:8,代码来源:WishlistController.php

示例11: auth

 public function auth($username, $password)
 {
     $user = User::findByUsername($username);
     if ($user && $user->validatePassword($password)) {
         return $user;
     } else {
         return null;
     }
 }
开发者ID:defektrain,项目名称:sgm-rest,代码行数:9,代码来源:ProfileController.php

示例12: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByUsername($this->username);
         $session = Yii::$app->session;
         $session->set('user_id', $this->_user->id);
     }
     return $this->_user;
 }
开发者ID:phpsong,项目名称:ExtJS5-Yii2,代码行数:14,代码来源:LoginForm.php

示例13: safeDown

 public function safeDown()
 {
     $auth = Yii::$app->authManager;
     $user = User::findByUsername($this->userLogin);
     $auth->revokeAll($user->id);
     $user->delete();
     $auth->remove($auth->getPermission($this->permissionName));
     $auth->remove($auth->getRole($this->roleName));
     return true;
 }
开发者ID:podvincev-n,项目名称:yii2-module-rbac,代码行数:10,代码来源:m150101_000004_rbac_superadmin_role.php

示例14: validatePassword

 /**
  * Validates the password.
  * This method serves as the inline validation for password.
  *
  * @param string $attribute the attribute currently being validated
  * @param array $params the additional name-value pairs given in the rule
  */
 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors()) {
         $user = User::findByUsername(Yii::$app->user->identity->username);
         $this->user = $user;
         if (!$user || !$user->validatePassword($this->password)) {
             $this->addError($attribute, '现用密码错误');
         }
     }
 }
开发者ID:BonVa,项目名称:colfans,代码行数:17,代码来源:ResetPassForm.php

示例15: login

 /**
  * Logs in a user using the provided username and password.
  * @return boolean whether the user is logged in successfully
  */
 public function login()
 {
     if ($this->validate()) {
         $user = User::findByUsername($this->username);
         Yii::$app->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0);
         return true;
     } else {
         return false;
     }
 }
开发者ID:nsanden,项目名称:Yii2-AspectMock,代码行数:14,代码来源:LoginForm.php


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