luyadev/luya-module-userauth

为特定 CMS 页面区域提供用户名和密码认证系统的插件。

1.1.2 2023-12-14 09:12 UTC

This package is auto-updated.

Last update: 2024-09-14 10:56:00 UTC


README

LUYA Logo

LUYA 前端用户认证

LUYA

为特定 CMS 页面区域提供用户名和密码认证系统。 它不包含前端新用户注册过程!

安装

  1. 通过 composer 安装扩展
composer require luyadev/luya-module-userauth
  1. 添加到配置
'modules' => [
    //...
    'userauthfrontend' => [
        'class' => 'luya\userauth\frontend\Module',
        'useAppViewPath' => false, // When enabled the views will be looked up in the @app/views folder, otherwise the views shipped with the module will be used.
    ],
    'userauthadmin' => 'luya\userauth\admin\Module',
],
  1. 以及用户组件
'components' => [
    //...
    'user' => [
        'class' => 'yii\web\User',
        'identityClass' => 'luya\userauth\models\User',
    ]
],
  1. 运行 ./luya migrate./luya import 命令。
  2. userauthfrontend 模块放置在 CMS 中指定的页面上。
  3. 添加配置变量标识符 userauth_redirect_nav_id,其值为步骤 5 中包含 userauthfrontend 的页面。
  4. 可选,您可以使用变量标识符 userauth_afterlogin_nav_id 配置用户在未提供 ref url 时应重定向到的导航 ID。

使用方法

安装后,您可以通过在页面“页面属性”面板中检查 保护页面 复选框来使用用户登录来保护任何给定的页面。重要:此设置不会由子页面继承,必须为每个需要保护的页面单独设置。