<commit_before># RoleAuth
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) 
[![Travis](https://img.shields.io/travis/PotatoPowered/RoleAuth.svg?style=flat-square)](https://travis-ci.org/PotatoPowered/RoleAuth)
[![Codecov](https://img.shields.io/codecov/c/github/PotatoPowered/RoleAuth.svg?style=flat-square)](https://codecov.io/github/PotatoPowered/RoleAuth)
[![Packagist](https://img.shields.io/packagist/dt/potatopowered/RoleAuth.svg?style=flat-square)](https://packagist.org/packages/potatopowered/RoleAuth)

## 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/RoleAuth
```
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 AooController to have it accessible in all controllers.
```
$this->loadComponent('RoleAuth');
```

## Usage

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'));
```
This assumes that you have role_id setup in the user linking to this plugins roles table.<commit_msg>fixed readme to have the correct packagist name<commit_after># RoleAuth
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) 
[![Travis](https://img.shields.io/travis/PotatoPowered/RoleAuth.svg?style=flat-square)](https://travis-ci.org/PotatoPowered/RoleAuth)
[![Codecov](https://img.shields.io/codecov/c/github/PotatoPowered/RoleAuth.svg?style=flat-square)](https://codecov.io/github/PotatoPowered/RoleAuth)
[![Packagist](https://img.shields.io/packagist/dt/potatopowered/RoleAuth.svg?style=flat-square)](https://packagist.org/packages/potatopowered/RoleAuth)

## 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');
```

## Usage

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'));
```
This assumes that you have role_id setup in the user linking to this plugins roles table.
{'fraction_non_alphanumeric': 0.12116209970287224, 'fraction_numerical': 0.0006602839220864972, 'mean_word_length': 5.488222698072805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3761849', 'n_tokens_mistral': 954, 'n_tokens_neox': 901, 'n_words': 280}