Yii Frame: Removing demo / admin accounts

So, I'm learning the Yii Framework, and there is this thing with admin / demo built-in accounts when you first create the sceleton application. I would like to delete them, even after uplodet to my web server, I can still log in with them. So where can I remove this, please?

+5
source share
2 answers

In the protected / components / folder, you will have the UserIdentity.php file, where these accounts are displayed by default, you can change / delete them.

You can use your db for authentication against your user table, something like this:

class UserIdentity extends CUserIdentity
{
 private $_id;
 public function authenticate()
 {
     $record=User::model()->findByAttributes(array('username'=>$this->username));
     if($record===null)
         $this->errorCode=self::ERROR_USERNAME_INVALID;
     else if($record->password!==md5($this->password))
         $this->errorCode=self::ERROR_PASSWORD_INVALID;
     else
     {
         $this->_id=$record->id;
         $this->setState('title', $record->title);
         $this->errorCode=self::ERROR_NONE;
     }
     return !$this->errorCode;
 }

 public function getId()
 {
     return $this->_id;
 }
}

Check out this article in the manual .

+12
source

/ UserIdentity.php, .

public function authenticate()
{
    $users=array(
        // username => password
        'demo'=>'demo',
        'admin'=>'admin',
    );

Yii Yii

+6

All Articles