Answer the question
In order to leave comments, you need to log in
Where is the admin site password stored in yii?
UserIdentity checked, there
<?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
{
const ERROR_ACCESS_DENIED = -1;
private $_id;
public function authenticate()
{
sleep(5);
$record = User::model()->findByAttributes(array('user_login'=>$this->username));
if (is_null($record))
$this->errorCode=self::ERROR_USERNAME_INVALID;
elseif ($record->user_pswd !== md5(md5($this->password)))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
elseif ($record->user_hospital_id !== HospitalList::model()->getHospitalId())
$this->errorCode=self::ERROR_ACCESS_DENIED;
else
{
$this->_id = $record->user_id;
$this->setState('title', $record->user_login);
$this->errorCode=self::ERROR_NONE;
}
// return ($this->errorCode === -1) ? $this->errorCode : false;
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}
}
Answer the question
In order to leave comments, you need to log in
In the database, in the users table, there is a password_hash field.
The password hash is stored in it by default.
there is no password_hash field in yii1, I may be wrong, but it seems that there is just a password field and md5 as a hash.
Out of the box, yii does not support authorization via DB
https://github.com/yiisoft/yii/blob/master/framewo...
Usually, inheriting CWebUser and rewriting the method to check the user from the DB would allow this.
You can simply write a migration to change the user's password, run it and log in safely, or simply generate a new md5 hash (just first check that md5 is used when checking the password), put it in the password field or whatever it is called in the user table and log in .
it turned out to be much more difficult, thanks for the support everyone))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question