originphp/user_authentication

OriginPHP 用户认证插件

安装: 36

依赖: 0

建议: 0

安全性: 0

星星: 1

关注者: 2

分支: 0

开放问题: 3

类型:originphp-plugin

3.4.2 2021-07-28 06:38 UTC

This package is auto-updated.

Last update: 2024-09-28 13:51:22 UTC


README

用户认证插件提供用户注册、发送欢迎邮件、更改密码、通过邮件通知验证用户邮箱地址等功能。此插件添加到您的应用程序中仅需不到2分钟,并提供您开始所需的一切。

安装

安装 UserAuthentication 插件

$ composer require originphp/user_authentication

设置

AppController 的 initialize 方法中加载 AuthComponent

class AppController extends Controller
{
    protected function initialize() : void
    {
        $this->loadComponent('Auth', [
            'loginAction' => '/login',
            'loginRedirect' => '/profile', # Set this to something valid
            'logoutRedirect' => '/login',
            'model' => 'UserAuthentication.User'
        ]);
    }
}

加载用户数据库模式(您可以稍后更改此模式)

$ bin/console db:schema:load UserAuthentication.schema

加载 Queue 模式,用于发送密码重置和邮箱验证通知。

$ bin/console db:schema:load queue

在您的 config/application.php 中设置 App.name

Config::write('App.name','Web Application');

使用方法

注册

https://:8000/signup

登录

https://:8000/login

这将带您到在 AppController 中设置的 loginRedirect 设置

开始密码重置过程

https://:8000/forgot_password

查看或编辑您的用户资料

https://:8000/profile

查看 API 令牌

https://:8000/token

如果您不打算使用 API 令牌,则可以将其从 config/routes.php 中删除

创建应用源代码

要将源代码安装到您的应用程序中并重命名命名空间,请输入

$ bin/console user-authentication:install

plugins/user_authentication/config/routes.php 复制并粘贴路由到 config/routes.php

plugins/user_authentication/database/schema.php 复制数据库模式到您的现有模式文件 database/schema.php 或新文件中。

卸载插件

$ composer remove originphp/user_authentication

下一步是什么

现在一切运行良好,是时候将用户认证插件和队列的方案复制到您的 application/schema.php 中。

测试插件

控制器集成测试需要您的 AppController 加载 AuthComponent,但其他测试在没有此组件的情况下也能正常运行。

UserAuthentication 插件和队列的模式加载到测试数据库中

$ bin/console db:schema:load --connection=test UserAuthentication.schema
$ bin/console db:schema:load --connection=test queue