If you want simple auth (login/signup/forgot), this is what you want! This extension has simple action what have added in controller. Extension has events:
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yiicod/yii2-auth "*"
or add
"yiicod/yii2-auth": "*"
to the require section of your composer.json.
run
php yii migrate/up --migrationPath=@yiicod/auth/migrations
Please note that messages are wrapped with Yii::t()
to support message translations, you should define default message source for them if you don't use i18n.
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\PhpMessageSource'
],
],
],
'components' => [
'auth' => [
'class' => 'yiicod\auth\Auth',
],
]
'bootstrap' => ['auth']
Copy yiicod\auth\controllers\WebUserController to controllers folder. After this you can use actions
/**
* Declares class-based actions.
* For change functional use AuthUserBehavior.
* Auth events:
*
* - beforeLogin(ActionEvent)
* - afterLogin(ActionEvent)
* - errorLogin(ActionEvent)
*
* - beforeSignup(ActionEvent)
* - afterSignup(ActionEvent)
* - errorSignup(ActionEvent)
*
* - beforeCheckRecoveryKey(ActionEvent)
* - afterCheckRecoveryKey(ActionEvent)
* - errorCheckRecoveryKey(ActionEvent)
*
* - beforeForgot(ActionEvent)
* - afterForgot(ActionEvent)
* - errorForgot(ActionEvent)
*
* - beforeLogout(ActionEvent)
* - afterLogout(ActionEvent)
*
*
* Global events
* yiicod.auth.controllers.webUser.[Action class name].[Event name (beforeLogin)]
*
*
*/
public function actions()
{
return ArrayHelper::merge(parent::actions(), [
'login' => [
'class' => \yiicod\auth\actions\webUser\LoginAction::className(),
],
'requestPasswordReset' => [
'class' => \yiicod\auth\actions\webUser\RequestPasswordResetAction::className(),
],
'logout' => [
'class' => \yiicod\auth\actions\webUser\LogoutAction::className(),
],
'signup' => [
'class' => \yiicod\auth\actions\webUser\SignupAction::className(),
],
'resetPassword' => [
'class' => \yiicod\auth\actions\webUser\ResetPasswordAction::className(),
],
]
);
}