devskyfly/yii-module-auth-security

v0.0.2 2021-11-25 14:25 UTC

This package is auto-updated.

Last update: 2024-11-25 21:23:25 UTC


README

Install

Composer

composer require devskyfly/yii-module-auth-security

Migrations

./yii migrate --migrationPath="vendor/devskyfly/yii-module-auth-security/src/migrations/"

Config

Config app access

'as accessfilter' => [
	'class' => 'yii\filters\AccessControl',
	'except' => [ 'site/login'],
	'rules' => [
		[
			'allow' => true,
			'roles' => ['@']
		],
	]
]

Config app components

[
	'authManager' => [
    	'class' => 'yii\rbac\PhpManager'
	],
	'user' => [
		'class' => 'yii\web\User',
		'identityClass' => 'devskyfly\yiiModuleAuthSecurity\models\auth\User',
		'loginUrl' => ['/site/login']
	]
]

Config app modules

'modules' => [
	'auth-security' => [
		"class" => "devskyfly\yiiModuleAuthSecurity\Module",
		"loginTitle" => "Login page",
    	"loginKeywords" => "Login keywords",
    	"loginDescription" => "Login description"
	] 
]

Config app controller

public function actions()
{
	return [
		'error' => [
			'class' => ErrorAction::class,
		],
		'login' => [
			'class' => LoginAction::class
		],
		'logout' => [
			'class' => LogoutAction::class
		],
	];
}

Config app login view by creating file /views/site/login.php

use devskyfly\yiiModuleAuthSecurity\widgets\auth\LoginForm;
echo LoginForm::widget(compact("loginForm"));