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


PHP Users::model方法代码示例

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


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

示例1: authenticate

 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = Users::model()->findByAttributes(array('username' => $this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password !== $user->encrypt($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $lastLogin = time();
             $this->setState('lastLoginTime', $lastLogin);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
     /*
     
     		$users=array(
     			// username => password
     			'demo'=>'demo',
     			'admin'=>'admin',
     		);
     		if(!isset($users[$this->username]))
     			$this->errorCode=self::ERROR_USERNAME_INVALID;
     		else if($users[$this->username]!==$this->password)
     			$this->errorCode=self::ERROR_PASSWORD_INVALID;
     		else
     			$this->errorCode=self::ERROR_NONE;
     		return !$this->errorCode;*/
 }
开发者ID:rralcala,项目名称:importacionesSrv,代码行数:39,代码来源:UserIdentity.php

示例2: authenticate

 public function authenticate()
 {
     $model = Users::model()->find("user_name=:user_name and user_password=:user_password and user_type = 'Administrator'", array(':user_name' => $this->username, ':user_password' => md5($this->password)));
     //        echo $model->user_name;exit;
     //        $users = array(
     //            // username => password
     //            'demo' => 'demo',
     //            'admin' => 'admin',
     //        );
     //        echo "<pre>";
     //        print_r($model);
     //        echo "</pre>";
     //        exit;
     if (!$model) {
         throw new CHttpException('503: Forbidden or Login Failed!', 'Username or Password is invalid or you\'re not registered');
         exit;
     }
     if ($model->user_name !== $this->username) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($model->user_password !== md5($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->user_id = $model->user_id;
         }
     }
     $this->errorCode = self::ERROR_NONE;
     return !$this->errorCode;
 }
开发者ID:augustus-amalejo,项目名称:palittayo,代码行数:29,代码来源:UserIdentity.php

示例3: authenticate

 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     //$user=Users::model()->findByAttributes(array('email'=>$this->email));
     $user = Users::model()->findByAttributes(array('email' => $this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->activate == 0) {
             $this->errorCode = 100;
         } else {
             if (!Users::model()->validatePassword($this->password, $user->password)) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->_id = $user->id;
                 $this->username = $user->name;
                 $this->setState('name', $this->username);
                 $this->setState('photo', $user->photo);
                 $this->setState('member', $user->member);
                 $this->setState('role', $user->occupation_id);
                 if ($user->member_type == '') {
                     $user->member_type = 'client';
                 }
                 $this->setState('member_type', $user->member_type);
                 $this->setState('freefoto', $user->freefoto);
                 $this->setState('isCrm', $user->crm == 1 ? true : false);
                 $this->errorCode = self::ERROR_NONE;
             }
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
开发者ID:schur-maksim,项目名称:happymoments.ua,代码行数:39,代码来源:UserIdentity.php

示例4: actionLogin

 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     $model = new LoginForm();
     // var_dump($_POST);
     // die;
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         // var_dump($_POST);
         // die;
         $model->attributes = $_POST['LoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($model->validate() && $model->login()) {
             // Yii::app()->user->returnUrl = Yii::app()->request->urlReferrer;
             // echo Yii::app()->request->urlReferrer;
             // die;
             // $this->redirect(Yii::app()->user->returnUrl);
             $record = Users::model()->findByAttributes(array('username' => $_POST['LoginForm']['username']));
             // echo "ssss";
             // var_dump($record);
             // die;
             Yii::app()->session['uid'] = $record['id'];
             Yii::app()->session['username'] = $record['username'];
             $this->redirect('/index.php?r=posts/index');
         }
     }
     // display the login form
     $this->render('login', array('model' => $model));
 }
开发者ID:RuiWangGit,项目名称:Blog,代码行数:36,代码来源:SiteController.php

示例5: loginIsExists

 /**
  * Проверка Логина и Email
  *
  * @param $attr
  * @param $params
  */
 public function loginIsExists($attr, $params)
 {
     if (!$this->hasErrors()) {
         /** @var Users $user */
         $user = Users::model()->find('login = :login AND email = :email', array(':login' => $this->login, ':email' => $this->email));
         if ($user === NULL) {
             $this->addError(__FUNCTION__, Yii::t('main', 'Аккаунт не найден.'));
         } elseif ($user->isBanned()) {
             $this->addError(__FUNCTION__, Yii::t('main', 'Аккаунт заблокирован, восстановление пароля невозможно'));
         } elseif (!$user->isActivated()) {
             $this->addError(__FUNCTION__, Yii::t('main', 'Аккаунт не активирован, восстановление пароля невозможно'));
         } else {
             // Ищю аккаунт на сервере
             try {
                 $l2 = l2('ls', $this->gs_list[$this->gs_id]['login_id'])->connect();
                 $res = $l2->getDb()->createCommand("SELECT * FROM {{accounts}} WHERE login = :login LIMIT 1")->bindParam('login', $this->login, PDO::PARAM_STR)->queryScalar();
                 if (!$res) {
                     $this->addError(__FUNCTION__, Yii::t('main', 'Аккаунт не найден.'));
                 }
             } catch (Exception $e) {
                 $this->addError(__FUNCTION__, $e->getMessage());
             }
         }
     }
 }
开发者ID:mmorpg2015,项目名称:ghtweb5,代码行数:31,代码来源:ForgottenPasswordForm.php

示例6: loadUser

 protected function loadUser()
 {
     if ($this->_model === null) {
         $this->_model = Users::model()->findByPk($this->id);
     }
     return $this->_model;
 }
开发者ID:thecocce,项目名称:forgot-password-in-yii,代码行数:7,代码来源:EWebUser.php

示例7: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     //        echo Yii::app()->session['roles'];
     if (!isset(Yii::app()->session['roles']) || !isset(Yii::app()->session['type'])) {
         Yii::log("You must choose roles first!");
         throw new CHttpException("You must choose roles first!");
         return;
     }
     $roles = Yii::app()->session['roles'];
     if (Yii::app()->session['type'] == 'ActionsUsers') {
         $user = Users::model()->find("username like '{$roles}'");
         if (!$user) {
             Yii::log("Wrong username!");
             throw new CHttpException("Wrong username!");
             return;
         }
     }
     $model = $this->loadModel($id);
     $array_action = array_map('trim', explode(",", trim($model->actions)));
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Actions'])) {
         if (Yii::app()->session['type'] == 'ActionsUsers') {
             $model->addUserRoles($_POST['Actions']);
             $this->redirect(array('user'));
         } else {
             $model->addGroupRoles($_POST['Actions']);
             $this->redirect(array('group'));
         }
     }
     $this->render('update', array('model' => $model, 'actions' => $this->listActionsCanAccess, 'actions_controller' => $array_action));
 }
开发者ID:jasonhai,项目名称:onehome,代码行数:37,代码来源:ControllersController.php

示例8: getModel

 private function getModel()
 {
     if (!$this->isGuest && $this->_model === null) {
         $this->_model = Users::model()->findByPk($this->id);
     }
     return $this->_model;
 }
开发者ID:42point,项目名称:Vinum,代码行数:7,代码来源:WebUser.php

示例9: authenticate

 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $username = strtolower($this->username);
     $user = Users::model()->find('LOWER(NOMER_SAKTI)=?', array($username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->validatePassword($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($user->STATUS == 0) {
                 $this->errorCode = self::ERROR_USERNAME_INVALID;
             } else {
                 $this->_id = $user->ID_USERS;
                 $this->username = $user->NOMER_SAKTI;
                 $this->setState('role', $user->ID_JENIS);
                 $this->errorCode = self::ERROR_NONE;
             }
         }
     }
     return $this->errorCode == self::ERROR_NONE;
     // $users=array(
     // 	// username => password
     // 	'demo'=>'demo',
     // 	'admin'=>'admin',
     // );
     // if(!isset($users[$this->username]))
     // 	$this->errorCode=self::ERROR_USERNAME_INVALID;
     // elseif($users[$this->username]!==$this->password)
     // 	$this->errorCode=self::ERROR_PASSWORD_INVALID;
     // else
     // 	$this->errorCode=self::ERROR_NONE;
     // return !$this->errorCode;
 }
开发者ID:eripahle,项目名称:rock20083,代码行数:42,代码来源:UserIdentity.php

示例10: authenticate

 public function authenticate()
 {
     $userIp = userIp();
     $this->_user = Users::model()->with('profile')->find('login = :login AND role = :role', array('login' => $this->username, 'role' => Users::ROLE_ADMIN));
     if ($this->_user === NULL) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (Users::validatePassword($this->password, $this->_user->password) === FALSE) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         // Сохраняю неудачную попытку входа
         UsersAuthLogs::model()->addErrorAuth($this->_user->getPrimaryKey());
     } elseif ($this->_user->activated == Users::STATUS_INACTIVATED) {
         $this->errorCode = self::ERROR_STATUS_INACTIVE;
     } elseif ($this->_user->role == Users::ROLE_BANNED) {
         $this->errorCode = self::ERROR_STATUS_BANNED;
     } elseif ($this->_user->profile->protected_ip && !in_array($userIp, $this->_user->profile->protected_ip)) {
         $this->errorCode = self::ERROR_STATUS_IP_NO_ACCESS;
     } else {
         $this->_id = $this->_user->getPrimaryKey();
         $this->_user->auth_hash = Users::generateAuthHash();
         $this->setState('auth_hash', $this->_user->auth_hash);
         $this->_user->save(FALSE, array('auth_hash', 'updated_at'));
         // Запись в лог
         UsersAuthLogs::model()->addSuccessAuth($this->_user->getPrimaryKey());
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
开发者ID:mmorpg2015,项目名称:ghtweb5,代码行数:27,代码来源:AdminIdentity.php

示例11: check_unique

 /**
  * Check unique rule
  */
 public function check_unique() {
         $user = Users::model()->find('User_Login=:login',
             array(':login'=>$this->User_Login));
         if($user != null) {
             $this->addError('User_Login','Login exists');
         }
 }
开发者ID:ranvijayj,项目名称:htmlasa,代码行数:10,代码来源:RegisterForm.php

示例12: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new UsersActions('create');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['UsersActions']) && isset($_POST['Username'])) {
         $name = Helper::toRegularString($_POST['Username']);
         $user = Users::model()->find("username like '{$name}'");
         if ($user) {
             //Check controller name, action name - PDQuang
             if ($_POST['UsersActions']['module'] == null) {
                 $checkController = ControllerActionsName::checkControllerActionsExist($_POST['UsersActions']['controller'], $_POST['UsersActions']['actions']);
             } else {
                 $checkController = ControllerActionsName::checkControllerActionsExist($_POST['UsersActions']['controller'], $_POST['UsersActions']['actions'], $_POST['UsersActions']['module']);
             }
             if (!$checkController) {
                 Yii::log('Controller, Module or Actions is wrong!');
                 throw new CHttpException('Controller, Module or Actions is wrong!');
             }
             $model->user_id = $user->id;
             $model->attributes = $_POST['UsersActions'];
             if ($model->save()) {
             }
             //$this->redirect(array('view','id'=>$model->id));
         }
         //
         //
         MyDebug::output($_POST);
         MyDebug::output($name);
         //
         //
         //
     }
     $this->render('create', array('model' => $model, 'actions' => $this->listActionsCanAccess));
 }
开发者ID:jasonhai,项目名称:onehome,代码行数:39,代码来源:UsersActionsController.php

示例13: authenticate

 public function authenticate()
 {
     $record = Users::model()->findByAttributes(array('username' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$this->enc && $record->password !== $record->generateHash($this->password) || $this->enc && $record->password !== $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($record->active == UserActiveStates::EMAIL_ACTIVATION) {
                 $this->errorCode = self::ERROR_NOT_ACTIVATED;
             } elseif ($record->active == UserActiveStates::BLOCKED) {
                 $this->errorCode = self::ERROR_BLOCKED;
             } else {
                 $this->_id = $record->id;
                 $this->errorCode = self::ERROR_NONE;
                 $log = new UsersSiteLogins();
                 $log->user_id = $record->id;
                 $log->when = new CDbExpression("NOW()");
                 $log->userIP = $_SERVER['REMOTE_ADDR'];
                 $log->save();
             }
         }
     }
     return !$this->errorCode;
 }
开发者ID:CrystReal,项目名称:Site_frontend,代码行数:26,代码来源:UserIdentity.php

示例14: getModel

 /**
  * @return object - Members AR Object
  */
 private function getModel()
 {
     if (!$this->isGuest && $this->_model === null) {
         $this->_model = Users::model()->findByPk($this->id, array('select' => 'role'));
     }
     return $this->_model;
 }
开发者ID:IuriiP,项目名称:yii-tracker,代码行数:10,代码来源:CustomWebUser.php

示例15: authenticate

 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     if (preg_match('/@/', $this->username)) {
         //$this->username can filled by username or email
         $record = Users::model()->findByAttributes(array('email' => $this->username));
     } else {
         $record = Users::model()->findByAttributes(array('username' => $this->username));
     }
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->password !== Users::hashPassword($record->salt, $this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->user_id;
             $this->setState('level', $record->level_id);
             $this->setState('profile', $record->profile_id);
             $this->setState('language', $record->language_id);
             $this->email = $record->email;
             $this->setState('username', $record->username);
             $this->setState('displayname', $record->displayname);
             $this->setState('creation_date', $record->creation_date);
             $this->setState('lastlogin_date', $record->lastlogin_date);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
开发者ID:OmmuOpenSource,项目名称:OOS-Company-Profile,代码行数:36,代码来源:UserIdentity.php


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