|
Server IP : 127.0.0.1 / Your IP : 127.0.0.1 Web Server : Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3 System : Windows NT WIN-R7LTCC7BPLI 6.3 build 9200 (Windows Server 2012 R2 Datacenter Edition) i586 User : GerbangSIPAD ( 0) PHP Version : 5.6.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF Directory (0777) : C:/xampp5/htdocs/sig-kolaka/models/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
namespace app\models;
use Yii;
use yii\base\NotSupportedException;
use yii\db\ActiveRecord;
use yii\web\IdentityInterface;
class User extends ActiveRecord implements IdentityInterface
{
/**
* Declares the name of the database table associated with this AR class.
*
* @return string
*/
public static function tableName()
{
return 'pbb.users';
}
/**
* Finds an identity by the given ID.
*
* @param int|string $id The user id.
* @return IdentityInterface|static
*/
public static function findIdentity($id)
{
return static::findOne(['id' => $id]);
}
/**
* Finds an identity by the given ID.
*
* @param int|string $id The user id.
* @return IdentityInterface|static
*/
public static function findByUsername($username)
{
return static::findOne(['username' => $username]);
}
/**
* Finds an identity by the given access token.
*
* @param mixed $token
* @param null $type
* @return void|IdentityInterface
*
* @throws NotSupportedException
*/
public static function findIdentityByAccessToken($token, $type = null)
{
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
/**
* Returns an ID that can uniquely identify a user identity.
*
* @return int|mixed|string
*/
public function getId()
{
return $this->getPrimaryKey();
}
/**
* Returns a key that can be used to check the validity of a given
* identity ID. The key should be unique for each individual user, and
* should be persistent so that it can be used to check the validity of
* the user identity. The space of such keys should be big enough to defeat
* potential identity attacks.
*
* @return string
*/
public function getAuthKey()
{
//return $this->auth_key;
}
/**
* Validates the given auth key.
*
* @param string $authKey The given auth key.
* @return boolean Whether the given auth key is valid.
*/
public function validateAuthKey($authKey)
{
//return $this->getAuthKey() === $authKey;
}
/**
* Generates "remember me" authentication key.
*/
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
}
/**
* Validates password.
*
* @param string $password
* @return bool
*
* @throws \yii\base\InvalidConfigException
*/
public function validatePassword($password)
{
return md5($password) === $this->password;
// return Yii::$app->security->validatePassword($password, $this->password_hash);
}
/**
* Generates password hash from password and sets it to the model.
*
* @param string $password
*
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
*/
public function setPassword($password)
{
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
}
}