<commit_before># Laravel 5 role based authentication

This is **Laravel 5** package for role based authenticating.

## Table of content

* [Known issues](#known-issues)
* [TODO](#todo)
* [Changes](#changes)
* [Features](#features)
* [Installation](#installation)
* [Models](#models)
    * [Group](#group-model)
    * [Role](#role-model)
    * [User](#user-model)
    * [UserPasswordReminder](#userpasswordreminder)
* [Helper classes](#helper-classes)
    * [AuthUser class](#authuser-class)
	    * [getUser](#authusergetuser)
        * [getUserId](#authusergetuserid)
		* [hasRole](#authuserhasrole)
		* [hasRoles](#authuserhasroles)
		* [isBlocked](#authuserisblocked)
    * [AuthRoute class](#authroute-class)
		* [getRoles](#authroutegetroles)
		* [hasCurrentUserAccess](#authroutehascurrentuseraccess)
		* [isPublic](#authrouteispublic)
* [Middleware](#middleware)
	* [hasAccess](#hasaccessmiddleware)
* [Smarty plugins](#smarty-plugins)
	* [has-role](#has-role-plugin)

## Known issues

* none

---
[Back to top](#laravel-5-role-based-authentication)

## TODO

* Fix incoming bugs
* Finish documentation
* Auto copy migration file

---
[Back to top](#laravel-5-role-based-authentication)

## Changes

Version 2.0

- **Laravel 5** support (requirement)
- Removed **AuthUser** and **AuthRoute** aliases
- Added **ViKon\Auth\AuthUser** and **ViKon\Auth\AuthRoute** singletons
- Package filters changed to **middleware** classes
- Removed **auth.home** filter (middleware)
- Code optimalization with Laravel 5 new features and conventions
- Service provider is now deferred

---
[Back to top](#laravel-5-role-based-authentication)

## Features

* Role based access
* Grouping roles
* Filter routes by individual roles

---
[Back to top](#laravel-5-role-based-authentication)

## Installation

To your `composer.json` file add following lines:

```javascript
// to your "require" object
"vi-kon/laravel-auth": "2.*"
```
In your Laravel 5 project add following lines to `app.php`:
```php
// to your providers array
'ViKon\Auth\AuthServiceProvider',
```
Optionally you can add aliases back to `app.php`:
```php
// to your aliases array
'AuthUser'  => 'ViKon\Auth\Facades\AuthUser',
'AuthRoute' => 'ViKon\Auth\Facades\AuthRoute',
```
To use middleware classes need to add aliases to `RouteServiceProvider`'s class `middleware` array:
```php
// to your middleware array
'auth.role' => 'ViKon\Auth\Middleware\HasAccess',
```

---
[Back to top](#laravel-5-role-based-authentication)

## Models

* [Group](#group-model)
* [Role](#role-model)
* [User](#user-model)
* [UserPasswordReminder](#userpasswordreminder-model)

Models are using pivot tables for many to many relations: `rel_role_group`, `rel_user_role`, `rel_user_group`.


---
[Back to top](#laravel-5-role-based-authentication)

### Group model

Group is for managing user roles as collection.
<commit_msg>Updated middleware installation<commit_after># Laravel 5 role based authentication

This is **Laravel 5** package for role based authenticating.

## Table of content

* [Known issues](#known-issues)
* [TODO](#todo)
* [Changes](#changes)
* [Features](#features)
* [Installation](#installation)
* [Models](#models)
    * [Group](#group-model)
    * [Role](#role-model)
    * [User](#user-model)
    * [UserPasswordReminder](#userpasswordreminder)
* [Helper classes](#helper-classes)
    * [AuthUser class](#authuser-class)
	    * [getUser](#authusergetuser)
        * [getUserId](#authusergetuserid)
		* [hasRole](#authuserhasrole)
		* [hasRoles](#authuserhasroles)
		* [isBlocked](#authuserisblocked)
    * [AuthRoute class](#authroute-class)
		* [getRoles](#authroutegetroles)
		* [hasCurrentUserAccess](#authroutehascurrentuseraccess)
		* [isPublic](#authrouteispublic)
* [Middleware](#middleware)
	* [hasAccess](#hasaccessmiddleware)
* [Smarty plugins](#smarty-plugins)
	* [has-role](#has-role-plugin)

## Known issues

* none

---
[Back to top](#laravel-5-role-based-authentication)

## TODO

* Fix incoming bugs
* Finish documentation
* Auto copy migration file

---
[Back to top](#laravel-5-role-based-authentication)

## Changes

Version 2.0

- **Laravel 5** support (requirement)
- Removed **AuthUser** and **AuthRoute** aliases
- Added **ViKon\Auth\AuthUser** and **ViKon\Auth\AuthRoute** singletons
- Package filters changed to **middleware** classes
- Removed **auth.home** filter (middleware)
- Code optimalization with Laravel 5 new features and conventions
- Service provider is now deferred

---
[Back to top](#laravel-5-role-based-authentication)

## Features

* Role based access
* Grouping roles
* Filter routes by individual roles

---
[Back to top](#laravel-5-role-based-authentication)

## Installation

### Basic

To your `composer.json` file add following lines:

```javascript
// to your "require" object
"vi-kon/laravel-auth": "2.*"
```
In your Laravel 5 project add following lines to `app.php`:
```php
// to your providers array
'ViKon\Auth\AuthServiceProvider',
```

---
[Back to top](#laravel-5-role-based-authentication)

### Aliases

Optionally you can add aliases back to `app.php`:
```php
// to your aliases array
'AuthUser'  => 'ViKon\Auth\Facades\AuthUser',
'AuthRoute' => 'ViKon\Auth\Facades\AuthRoute',
```

---
[Back to top](#laravel-5-role-based-authentication)

### Middleware

To use middleware class assigned to rout need to assign short-hand key to `middleware` property of your `app/Providers/RouteServiceProvider` class:
```php
// to your middleware array
'auth.role' => 'ViKon\Auth\Middleware\HasAccess',
```
To use middleware globaly (run on every HTTP request) enough to add to your `middleware` property of your `app/Http/Kernel.php` class.

More information about [Middleware usage](http://laravel.com/docs/master/middleware).

---
[Back to top](#laravel-5-role-based-authentication)

## Models

* [Group](#group-model)
* [Role](#role-model)
* [User](#user-model)
* [UserPasswordReminder](#userpasswordreminder-model)

Models are using pivot tables for many to many relations: `rel_role_group`, `rel_user_role`, `rel_user_group`.

---
[Back to top](#laravel-5-role-based-authentication)

### Group model

Group is for managing user roles as collection.

{'fraction_non_alphanumeric': 0.1546826813828924, 'fraction_numerical': 0.004869339392955689, 'mean_word_length': 4.976721629485936, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '1386950', 'n_tokens_mistral': 2113, 'n_tokens_neox': 1982, 'n_words': 496}