mihaildev / yii2-user
Yii2 Simple User Module
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-10-26 19:59:13 UTC
README
Простая авторизация для сайта
Установка и Настройка
- добавляем в composer.json - "mihaildev/yii2-user": "*"
- замена стандартной компоненты
'components' => [ 'user' => [ 'class' => 'mihaildev\user\Component', 'enableAutoLogin' => true, 'loginUrl' => ['/site/login'], //'loginUrl' => ['/user/login'], 'userList' => [ '1' => [// id value 'id' => '1', 'username' => 'admin', 'password' => 'admin', ] ], 'authKeySalt' => 'SomeSecreteValue' ],
- добавление в контроллер действий
class SiteController extends Controller { /** * @inheritdoc */ public function behaviors() { return [ 'access' => [ 'class' => AccessControl::className(), 'only' => ['logout'], 'rules' => [ [ 'actions' => ['logout'], 'allow' => true, 'roles' => ['@'], ], ], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ], ], ]; } public function actions() { return [ 'login' => [ 'class' => 'mihaildev\user\action\LogIn', //'template' => 'login' // default: @mihaildev/user/views/login.php, //'defaultUrl' => ['/site/index'], ], 'logout' => 'mihaildev\user\action\LogOut', ]; }
или добавляем контроллер mihaildev\user\Controller
'controllerMap' => [ 'user' => [ 'class' => 'mihaildev\user\Controller', //'template' => 'login' // default: @mihaildev/user/views/login.php, //'defaultUrl' => ['/site/index'], ]