infotechnohelp/cakephp-users

适用于 CakePHP 3 的插件

安装: 6

依赖: 0

建议者: 0

安全: 0

星标: 0

分支: 0

类型:cakephp-plugin

dev-master 2018-09-21 14:48 UTC

This package is auto-updated.

Last update: 2024-09-17 22:19:33 UTC


README

依赖关系

后端

  • CakePHP 3+

前端

  • jQuery 2+ (由 loginForm 元素要求)
  • Vue 2+ (由 registerForm 元素要求)

安装

bin/cake plugin load -r Infotechnohelp/Users

bin/cake migrations migrate -p Infotechnohelp/Users

  • APP/src/Controller/AppController

class AppController extends AuthenticationController (use Infotechnohelp\Users\Controller\AuthenticationController;)

  • APP/config/bootstrap.php
Configure::write('Infotechnohelp/Users', [
    'registrationAllowed' => boolean,
    'path' => [
        'loginAction'   => '/any/path' | null,
        'loginRedirect' => '/any/path' | null,
    ],
    'message' =>[
        'loginAlert' => 'Any message' | null,
        'registrationSuccess' => 'Any message' | null,
        'registrationFailure' => 'Any message' | null,
        'confirmationLinkSent' => 'Any message' | null,
        'emailConfirmed' => 'Any message' | null,
        'emailAlreadyConfirmed' => 'Any message' | null,
        'resetPassword' => 'Any message' | null,
    ],
    'css'  => [
        'loginForm' => 'loginForm' | null, (corresponds to APP/webroot/css/loginForm.css)
        'registerForm' => 'registerForm' | null,
    ],
    'email' => [
        'fromName' => 'Any string' | null,
        'fromEmail' => 'email@email.com' | null,
        'projectUrl' => 'http://any.url.com' | null,
        'emailConfirmationSubject' => 'Any subject' | null,
        'emailConfirmationMessage' => "Hello! \n %sconfirm-email/%s \n\n %s team" | null,
    ],
]);

默认值:(当未添加配置时)

  • registrationAllowed → true
  • path.loginAction → APP/login
  • path.loginRedirect → APP
  • message.loginAlert → 'User cannot be identified'
  • message.registrationSuccess → 'User was successfully registered'
  • message.registrationFailure → 'An error occurred during registration'
  • css.loginForm → PLUGIN/webroot/css/loginForm.css
  • css.registerForm → PLUGIN/webroot/css/registerForm.css

使用方法

表格
  • users
  • user_email_confirmations
连接路径

APP/login = APP/users/login

APP/logout = APP/users/logout

API 层

APP/users/register = APP/users/api/users/register

APP/users/login = APP/users/api/users/login

APP/users/logout = APP/users/api/users/logout

本地化

loginForm 元素要求

  • 用户名或邮箱
  • 密码
  • 登录
  • 忘记密码了?
  • 注册
  • 用户无法识别

registerForm 元素要求

  • 用户名
  • 邮箱
  • 密码
  • 重复密码

消息

  • 用户成功注册
  • 注册过程中发生错误

验证错误

  • 用户名不能为空
  • 用户名已被使用
  • 邮箱不能为空
  • 邮箱已被使用
  • 密码不匹配
  • 密码不能为空