Skip to content

Instantly share code, notes, and snippets.

@jokosusilo
Last active August 29, 2015 14:00
Show Gist options
  • Save jokosusilo/f08f15346d7636437d01 to your computer and use it in GitHub Desktop.
Save jokosusilo/f08f15346d7636437d01 to your computer and use it in GitHub Desktop.
<?php
/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
class UserIdentity extends CUserIdentity
{
private $id;
public function authenticate() {
$record = MsUser::model()->findByAttributes(array('kode_skpd' => $this->username));
if ($record === null)
$this->errorCode = self::ERROR_USERNAME_INVALID;
else if ($record->password !== $this->password)
$this->errorCode = self::ERROR_PASSWORD_INVALID;
else {
$this->id = $record->id;
$this->setState('roles', $record->hakakses);
$this->errorCode = self::ERROR_NONE;
}
return !$this->errorCode;
}
public function getId() {
return $this->id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment