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


PHP User::findIdentity方法代码示例

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


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

示例1: actionIndex

 /**
  * Lists all ApiLogs models.
  * @return mixed
  */
 public function actionIndex()
 {
     $user = User::findIdentity(Yii::$app->user->id);
     $user->level == 1 ? $searchModel = new ApiLogsSearch() : ($searchModel = new UserApiLogsSearch());
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
开发者ID:Bladefidz,项目名称:ocfa_yii,代码行数:11,代码来源:ApiLogsController.php

示例2: signup

 /**
  * Signs user up.
  *
  * @return true|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->phone = $this->phone;
         $user->email = $this->email;
         $randLength = mt_rand(6, 9);
         $this->password = Yii::$app->security->generateRandomString($randLength);
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             $profile = new Profile();
             $profile->user_id = $user->id;
             $profile->name = $this->name;
             //если в куках есть id аффилиата, сохраняем его
             $affiliateId = (int) Yii::$app->request->cookies['affiliate'];
             if ($affiliateId > 0 && User::findIdentity($affiliateId)) {
                 $profile->user_affiliate_id = $affiliateId;
             }
             $profile->save();
             return $this->sendRegistrationEmail();
         }
     }
     return null;
 }
开发者ID:eugene-kei,项目名称:yii2-micro-school-crm,代码行数:30,代码来源:SignupForm.php

示例3: findPasswords

 public function findPasswords($attribute, $params)
 {
     $user = User::findIdentity(Yii::$app->user->id);
     if (!$user->validatePassword($this->currentPassword)) {
         $this->addError($attribute, 'Old password is incorrect');
     }
 }
开发者ID:ncuong,项目名称:lifeguard,代码行数:7,代码来源:ChangePasswordForm.php

示例4: rules

 public function rules()
 {
     return [[['password', 'email', 'title'], 'required', 'on' => self::SCENARIO_NEW], [['email', 'title'], 'required', 'on' => self::SCENARIO_EDIT], ['password', 'string', 'min' => Yii::$app->params['passLength']], ['password_repeat', 'compare', 'compareAttribute' => 'password', 'message' => Yii::t('app', "Passwords don't match")], [['ssid'], 'default', 'value' => helper::getSsid()], [['ssid', 'shop_id'], 'integer'], [['title'], 'string', 'max' => 100], [['description'], 'string', 'max' => 250], 'emailPattern' => ['email', 'email'], 'emailLength' => ['email', 'string', 'max' => 255], 'emailUniqueEdit' => ['email', function ($attribute) {
         if (User::findByEmail($this->email)) {
             $this->addError($attribute, $this->email . Yii::t('app', 'Email already exist'));
         }
     }, 'when' => function () {
         $user = User::findByEmail($this->email);
         if (!empty((array) $user)) {
             return Yii::$app->user->id != $user->id;
             // do not check for current user (my email)
         }
     }, 'on' => self::SCENARIO_EDIT], 'emailUniqueNew' => ['email', function ($attribute, $params) {
         $user = User::findByEmail($this->{$attribute});
         if (!empty((array) $user)) {
             $this->addError($attribute, Yii::t('app', 'Email already exist'));
         }
     }, 'on' => self::SCENARIO_NEW], 'emailTrim' => ['email', 'trim'], 'oldPassCheck' => ['password_old', function ($attribute) {
         $user = User::findIdentity($this->id);
         if (!empty((array) $user)) {
             if ($user->validatePassword($this->password_old)) {
                 $this->addError($attribute, Yii::t('app', 'Password Do not match'));
             }
         }
     }, 'on' => self::SCENARIO_EDIT]];
 }
开发者ID:best-nazar,项目名称:gb-yii2,代码行数:26,代码来源:managerAssistant.php

示例5: searchTreeView

 public function searchTreeView($params)
 {
     $user = User::findIdentity(Yii::$app->user->id);
     $query = User::find();
     $query->where('status != ' . User::STATUS_DELETED);
     //        $query->andwhere('id != '.Yii::$app->user->id);
     $query->andwhere('referrer IS NULL OR referrer = "' . $user->code . '" ');
     //        if($params == null){
     //            $query->andwhere(['referrer'=>$user->code]);
     //
     //        }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC, 'first_name' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['state' => $this->state, 'sex' => $this->sex, 'zip' => $this->zip, 'code' => $this->code, 'referrer' => $this->referrer, 'graduate_high_school' => $this->graduate_high_school]);
     if ($this->status != null) {
         $query->andFilterWhere(['status' => $this->status]);
     }
     $query->andFilterWhere(['like', 'first_name', $this->first_name])->orFilterWhere(['like', 'last_name', $this->first_name]);
     $query->andFilterWhere(['like', 'email', $this->email]);
     $query->andFilterWhere(['like', 'city', $this->city]);
     $query->andFilterWhere(['like', 'mobile', $this->mobile]);
     return $dataProvider;
 }
开发者ID:ncuong,项目名称:lifeguard,代码行数:28,代码来源:ReferrerSearch.php

示例6: actionIndex

 public function actionIndex($id)
 {
     $user = User::findIdentity($id);
     $comments = Comment::getRecentComments();
     $sidebarCategories = Category::getSidebarCategories();
     $tags = Tag::getTagList();
     return $this->render('index', ['user' => $user, 'comments' => $comments, 'sidebarCategories' => $sidebarCategories, 'tags' => $tags]);
 }
开发者ID:BorisMatonickin,项目名称:yiicms,代码行数:8,代码来源:ProfileController.php

示例7: resetPassword

 public function resetPassword()
 {
     $this->_user = User::findIdentity(Yii::$app->user->id);
     if (!Yii::$app->getSecurity()->validatePassword($this->password, $this->_user->password_hash)) {
         throw new InvalidParamException(Yii::t('User', 'source_password_error'));
     }
     $this->_user->setPassword($this->new_password);
     return $this->_user->save(false);
 }
开发者ID:duanbiaowu,项目名称:sailshop,代码行数:9,代码来源:ResetPasswordForm.php

示例8: save_signature

 public function save_signature()
 {
     $user = User::findIdentity(Yii::$app->user->id);
     $user->signature = Functions::clear_text($this->signature);
     if ($user->save()) {
         return Html::decode($user->signature);
     }
     return false;
 }
开发者ID:BeerMan88,项目名称:yii,代码行数:9,代码来源:ChangeSignature.php

示例9: __construct

 /**
  * Creates a form model given a token.
  *
  * @param  string                          $token
  * @param  array                           $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($id, $config = [])
 {
     $this->_user = User::findIdentity($id);
     if (!$this->_user) {
         throw new InvalidParamException('Unable to find user!');
     }
     $this->id = $this->_user->id;
     $this->username = $this->_user->username;
     parent::__construct($config);
 }
开发者ID:wadeshuler,项目名称:yii2-members-system,代码行数:17,代码来源:ChangeUserPasswordForm.php

示例10: statusVerified

 /**
  * Check status verified
  * @param  [type] $user_id [description]
  * @return [type]       [description]
  */
 function statusVerified($user_id)
 {
     $profile = static::findOne(['user_id' => $user_id, 'created_by' => $user_id]);
     $user = User::findIdentity($user_id);
     if ($profile->email != $user->email) {
         $email = $profile->email . ' <span class="label label-warning">Not Verified</span>';
     } elseif ($profile->email === $user->email) {
         $email = $profile->email . ' <span class="label label-success">Verified</span>';
     }
     return $email;
 }
开发者ID:WillymarJ,项目名称:phpindonesia.or.id-membership,代码行数:16,代码来源:ProfileCrud.php

示例11: save_age_date

 public function save_age_date()
 {
     $user = User::findIdentity(Yii::$app->user->id);
     if ($user->age_date != $this->age_date) {
         $user->age_date = $this->age_date;
         if ($user->save()) {
             return Functions::get_is_age_from_date($this->age_date);
         }
     }
     return false;
 }
开发者ID:BeerMan88,项目名称:yii,代码行数:11,代码来源:ChangeAge.php

示例12: actionInputPenduduk

 public function actionInputPenduduk()
 {
     // get user from class User by id
     $getUser = User::findIdentity(Yii::$app->user->id);
     // check user level, if level equals 1 then user is an admin, he can through frontend or backend, if else user is a user, he only can through frontend
     if ($getUser->level == 1) {
         return $this->render('input_penduduk');
     } else {
         return $this->redirect(['../../frontend/web/', 'id' => Yii::$app->user->id]);
     }
 }
开发者ID:Bladefidz,项目名称:ocfa_yii,代码行数:11,代码来源:SiteController.php

示例13: execute

 /**
  * Проверка доступа к ресурсу.
  *
  * @param int $userId Идентификатор пользователя.
  * @param \yii\rbac\Item $item Роль.
  * @param array $params Параметры для проверки доступа.
  * @return bool
  */
 public function execute($userId, $item, $params)
 {
     // Если не указан обязательный параметр action.
     if (!isset($params['action']) || !in_array($params['action'], $this->actions)) {
         return false;
     }
     // Пользователь не может редактировать и удалять сам себя.
     if (in_array($params['action'], [self::ACTION_EDIT_USER, self::ACTION_DELETE_USER]) && $userId == $params['userId']) {
         return false;
     }
     // Админам, кроме редактирования, удаления самомго себя разрешаются все действия.
     $user = User::findIdentity($userId);
     if ($user->isAdmin()) {
         return true;
     }
     // Менеджерам запрещено выполнять какие-либо действия на пользователями.
     if ($user->isManager()) {
         return false;
     }
     // Если добавление пользователя.
     if ($params['action'] == self::ACTION_ADD_USER) {
         return true;
     } else {
         // Если не указан идентификатор пользователя, над которым выполняется действие.
         if (!isset($params['userId'])) {
             return false;
         }
         $actionUser = User::findIdentity($params['userId']);
         // Если пользователь, на которым выполняется действие из другой компании, запрещаем что-либо делать.
         if ($actionUser->getCompanyId() != $user->getCompanyId()) {
             return false;
         }
         // Если пользователь, над которым выполняется действие администратор, запрещаем действие.
         if ($actionUser->isAdmin()) {
             return false;
         }
         // Если действие редактирование или удаление и если пользователь оовнер или пользователь, который выполняет
         // действие босс и пользователь, над которым выполняется тоже босс, разрешаем выполнение.
         $isChangeUserAction = in_array($params['action'], [self::ACTION_EDIT_USER, self::ACTION_DELETE_USER]);
         if ($isChangeUserAction && ($user->isOwner() || $user->isBoss() && ($actionUser->isBoss() || $actionUser->isManager()))) {
             return true;
         }
         // Просматривать можно и овнерам и боссам.
         if (self::ACTION_VIEW_USER == $params['action']) {
             return true;
         }
         return false;
     }
 }
开发者ID:vlamug,项目名称:landing-page-crm,代码行数:57,代码来源:UserAccessRule.php

示例14: actionIndex

 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     if (Yii::$app->user->isGuest) {
         return $this->render('index');
     } else {
         $user = User::findIdentity(Yii::$app->user->id);
         //var_dump($user);die;
         $type = $user['type'];
         if ($type == 'Tutor' || $type == 'tutor') {
             return $this->redirect('index.php?r=file/index');
         } else {
             return $this->render('studentHome');
         }
     }
 }
开发者ID:vihanga-liyanage,项目名称:feed-cloud,代码行数:20,代码来源:SiteController.php

示例15: successAuthclientCallback

 /**
  * TODO: допилить, разделить
  * @param \yii\authclient\BaseClient $client
  * @return bool
  */
 public function successAuthclientCallback($client)
 {
     $attributes = $client->getUserAttributes();
     //TODO: добавить обновление данных
     if (!Yii::$app->getUser()->isGuest) {
         $userAuthClient = \common\models\UserAuthclient::findOne(["user_id" => Yii::$app->user->getId(), "provider" => $client->getId(), "provider_identifier" => $attributes["id"]]);
         if (!$userAuthClient) {
             $userAuthClient = new \common\models\UserAuthclient(["user_id" => Yii::$app->user->getId(), "provider" => $client->getId(), "provider_identifier" => $attributes["id"], "provider_data" => serialize($attributes)]);
             $userAuthClient->save();
         }
     } else {
         $userAuthClient = \common\models\UserAuthclient::findOne(["provider" => $client->getId(), "provider_identifier" => $attributes["id"]]);
         if ($userAuthClient) {
             $user = \common\models\User::findIdentity($userAuthClient->getUserId());
             if ($user) {
                 return Yii::$app->user->login($user, 0);
             }
         }
     }
 }
开发者ID:skeeks-cms,项目名称:app-basic,代码行数:25,代码来源:SiteController.php


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