achertovsky/yii2-user-advanced

该包已弃用,不再维护。未建议替代包。

轻量级用户扩展,支持oauth和经典邮箱登录

安装: 9

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

公开问题: 0

类型:yii2-extension

0.1.0 2021-12-04 08:47 UTC

This package is auto-updated.

Last update: 2022-06-28 09:10:52 UTC


README

为yii2-advanced-template ~2.0.14创建并测试。其他支持未经保证,但预期将开发。

将覆盖默认模板用户交互,包括

  • 路由
  • 身份类

安装,手册

美观URL

预期适用于已启用美观路由和定义基础路由的模板,因此

要使其工作,请取消注释\添加 @app config/main.php 中的部分组件

'urlManager' => [
    /**
     * 'baseUrl' is not defined at just-cloned template. expected it to be added
     */
    'baseUrl' => '/',
    //'baseUrl' => '/backend', //for backend
    
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
    ],
],

添加到前端/后端组件 -> 请求 'baseUrl',

'request' => [
    /**
     * ...
     */
    'baseUrl' => '',
    //'baseUrl' => '/backend', //for backend
],

添加到模块部分

'modules' => [
    'user' => [
        'class' => 'achertovsky\user\Module',
        /**
        * Current email will be used as sender in any email of this module
        *
        * @var string
        */
        'senderEmail' => 'desired.email@mailbox.com', // desired email
    ],
],

oauth

要使其工作,只需在 components -> authClientCollection 中配置相应的类 facebook, google 确实有效。其他未测试,抱歉

'authClientCollection' => [
    'class' => 'yii\authclient\Collection',
    'clients' => [
        /**
         * key name gonna be displayed on signup/login page
         * name it as you want it to displayed
         */
        'facebook' => [ 
            'class' => 'yii\authclient\clients\Facebook',
            'clientId' => '',
            'clientSecret' => '',
        ],
        // ... so on
    ],
],

迁移

路径通过引导程序添加,只需 ./yii migrate/up

建议

  • 强烈建议在默认 frontend\controllers\SiteController 中执行以下操作

    • 移除 actionLogin
    • 移除 actionLogout
    • 移除 actionSignup
    • 移除 actionRequestPasswordReset
    • 移除 actionResetPassword
    • 移除 actionVerifyEmail
    • 移除 actionResendVerificationEmail
    • 移除行为(除非您需要它)
    • 从 actions() 方法中移除 captcha 操作
  • 强烈建议在默认 backend\controllers\SiteController 中执行以下操作

    • 移除 actionLogin
    • 移除 actionLogout
    • 移除行为(除非您需要它)
  • 清理未使用的类

    • frontend\models\ResendVerificationEmailForm
    • frontend\models\PasswordResetRequestForm
  • 清理未使用的视图

    • backend/views/site/login.php
    • frontend/views/site/login.php
    • frontend/views/site/requestPasswordResetToken.php
    • frontend/views/site/resendVerificationEmail.php
    • frontend/views/site/resetPassword.php
    • frontend/views/site/signup.php
    • common/mail/*