I have been trying to search on the Internet how to write the code in Yii framework 2.0 so that user can login with the credentials stored in the database and not from the array, prefixed in models/User.php. I know how to do that in Yii 1. But in Yii 2.0, I really don't know how to do that. Since Yii 2.0 has not been released yet (only the beta version is available), I could not find many Yii 2.0 tutorials on the Internet about logging-in with the database.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You can implement database user management using extesions like https://github.com/amnah/yii2-user.
OR
If you want to write your own custom script to manage the users you can override Yii2 identityClass.
In the component section of your config add:
Please note that your user model MUST IMPLEMENT \yii\web\IdentityInterface
Here is the example of the model class that you can use to implement database authentication
I hope that would be helpful to you . Cheers :)
Check the Yii2 advanced application:
https://github.com/yiisoft/yii2-app-advanced
There full implementation of signup, login, resetPassword for Users stored in DB.