Yii Login Prozess

linkaiyi
Follow

Passwort Generieren

crypt(password, hash):

https://www.yiiframework.com/wiki/425/use-crypt-for-password-storage

the hash value can be used to calculated against password. Only the first 29 characters will be used as hash to generate password value

that why use $this->setPassword(password)

Field validation

the Model field without validation rule can not be updated by form. Therefore at least set validation rule to ‘unsafe’

Model View to display option value for field

define get_Field_Display()

 public function getStatusDisplay()
    {
        $STATUS_CHOICE = ['0'=>'Deleted', '9'=>'Inactive', '10'=>'Active'];
        return $STATUS_CHOICE[strval($this->status)];
    }

add function to DetailView

<?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'username',
            'auth_key',
            'password_hash',
            'password_reset_token',
            'email:email',
            [
                'label' => 'Status',
                'value'=> $model->getStatusDisplay(),
            ],
            'created_at:datetime',
            'updated_at:datetime',
            'verification_token',
        ],
    ]) ?>
Object has 0 attachments

Was this article helpful?

This article is viewed 63 times!

Recent Viewed Articles

0 Comments

Leave a Comment

Support