本文整理汇总了PHP中Accounts::Model方法的典型用法代码示例。如果您正苦于以下问题:PHP Accounts::Model方法的具体用法?PHP Accounts::Model怎么用?PHP Accounts::Model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Accounts
的用法示例。
在下文中一共展示了Accounts::Model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = Accounts::Model()->findByAttributes(array('userName' => $this->username));
if ($user === null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} else {
if ($user->password !== md5($user->salt . $this->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->_id = $user->accountID;
$this->setState('trackingGroupID', $user->trackingGroupID);
$this->setState('userLevel', $user->userLevel);
$this->errorCode = self::ERROR_NONE;
}
}
return !$this->errorCode;
}
示例2: getUsers
public function getUsers()
{
if (Yii::app()->user->userLevel == 1) {
return Accounts::Model()->findAll();
} else {
return Accounts::Model()->findByPk(Yii::app()->user->id);
}
}