yiicod / yii2-auth
The simple auth(login,signup,forgot) with powerful extension for the Yii2 framework
Installs: 125
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 2
Open Issues: 0
Type:yii-extension
Requires
This package is auto-updated.
Last update: 2024-10-27 00:28:38 UTC
README
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:
Installation
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' ], ], ],
Config
'components' => [ 'auth' => [ 'class' => 'yiicod\auth\Auth', ], ] 'bootstrap' => ['auth']
Using
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(), ], ] ); }