O
O
onahapa2015-02-11 20:04:18
Yii
onahapa, 2015-02-11 20:04:18

Authentication in Yii. as?

Hello. I'm studying the Yii tutorial, I had a problem with authentication.
As it is written in the manual, I created the tbl_user table, we are preparing the sql script (which came with yii) and threw 21 users there with username = test$i and password = pass$i.
After reading this guide, I did not understand what to do with this

$identity=new UserIdentity($username,$password);
$identity->authenticate();
switch($identity->errorCode)
{
    case UserIdentity::ERROR_NONE:
        Yii::app()->user->login($identity);
        break;
    …
}

maybe because of this I can't get through authentication, or maybe because of something else.
Thought it might cache the password, commented out the trail. code (if done correctly)
public function hashPassword($password)
    {
        return CPasswordHelper::hashPassword($password);
    }
, but the result is 0
How to be? thank.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Frank, 2015-02-12
@Akellacom

I advise you to read more about Yii.
And the code that you cited above about identity is the code used in the model.
See code examples of how it is implemented https://github.com/yiisoft/yii/tree/master/demos/b...
And about the hashPassword method, it does not cache, but creates an md5 hash, not to store the password in clear text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question