Login with Yii 2.0

Hi,

I have a this table for user :


[sql]`userProduct` (

  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,

  `email` varchar(255) NOT NULL,

  `user` varchar(255) NOT NULL,

  `password` varbinary(224) DEFAULT '',

  `type` enum('admin','nobody') DEFAULT 'nobody',

  `token` varchar(32) NOT NULL DEFAULT '',

  `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

  `created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',

  PRIMARY KEY (`id`),

  UNIQUE KEY `email` (`email`),

  KEY `token` (`token`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;[/sql]

[font=“Arial”][size=“4”]Do you know if i need another fields in my table[/size] [/font]:unsure:

So I used Gii (code generator) du Yii 2.0

So I generated the Model :

This generator generates an ActiveRecord class for the specified database table.

>> Table Name :userProduct

>> Model Class:UserProduct

Here is code File : models\UserProduct.php

And then I used CRUD Generator

This generator generates a controller and views that implement CRUD (Create, Read, Update, Delete) operations for the specified data model.

>> Model Class: app\models\UserProduct

>> Model Class: app\models\UserProductSearch

>> Model Class: appcontrollers\UserProductController

Here is code File :

generated controllers\UserProductController.php

generated models\UserProductSearch.php

generated views\userProduct\_form.php

generated views\userProduct\_search.php

generated views\userProduct\create.php

generated views\userProduct\index.php

generated views\userProduct\update.php

generated views\userProduct\view.php

:unsure:

Now I don’t know what I must do and how I must it ?

:unsure:

[font="Arial Black"]I need a login page.

If an user haven’t an account this user can only consulate the product page (only view he cannot update neither delete those items) :mellow:

If this user have an account he can update / delete those items and create new item on the product page[/font]

:mellow:

[size="5"]So 1st step what I must do it with my Yii2.0

Thanks[/size]

http://www.yiiframework.com/doc-2.0/guide-security-authentication.html#authentication

http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#authorization

ACF is explained in the Authorization section.

The advanced template uses login from db.

A wiki article about simple RBAC if you need that.

http://www.yiiframework.com/wiki/771/rbac-super-simple-with-admin-and-user/

Thanks Tri :D