potatopowered/role-auth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

potatopowered/role-auth

Composer 安装命令:

composer require potatopowered/role-auth

包简介

The RoleAuth Component aims to make authorization in CakePHP 3.x applications as simple as can be.

README 文档

README

Software License Travis Codecov Packagist

Description

The RoleAuth Component aims to make authorization in CakePHP 3.x applications as simple as can be.

Installation Guide

Add the component to your composer.json you can do this easily using composer itself.

composer require potatopowered/role-auth

Add the roles table using migrate.

bin/cake migrations status -p RoleAuth

Load the RoleAuth Component with the other components in the initialize function of your AppController to have it accessible in all controllers.

$this->loadComponent('RoleAuth.RoleAuth');

Advanced Load

$this->loadComponent('RoleAuth.RoleAuth', [
  'roles_table' => 'roles',
  'admin_role' => 'Admin',
  'default_role' => 'User'
]);

Usage

This assumes that you have role_id setup in the user linking to this plugins roles table.

Check if a user is an admin

To use the RoleAuth component to check if a user is an admin you can make a call as such. The following will check the logged in users role_id and verify that they are an admin or not. The result is boolean.

$this->RoleAuth->isAdmin($this->Auth->user('role_id'));

Check if a user has a specific role

To use the RoleAuth component to check if a user is a specific role you can make a call as such. The following will check the logged in users role_id and verify that they have a role or not. The result is boolean.

$this->RoleAuth->hasRole('YourRole', $this->Auth->user('role_id'));

Set all role variables

To use the RoleAuth component to check the users role and set all role variables in one shot you can make a call as such. The following will check the logged in users role_id and verify that they have a role or not. The result is boolean.

$this->RoleAuth->setRoles($this->Auth->user());

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固