An open API service indexing awesome lists of open source software.

https://github.com/akunbeben/fortify-role

Multi Roles authentication package for Fortify.
https://github.com/akunbeben/fortify-role

auth authentication fortify hacktoberfest laravel laravel-package laravel-ui multi-authentication roles

Last synced: 23 days ago
JSON representation

Multi Roles authentication package for Fortify.

Awesome Lists containing this project

README

          

# Fortify Role
Basic Multi Roles authentication package for Fortify.

[![GitHub license](https://img.shields.io/github/license/akunbeben/fortify-role?style=for-the-badge)](https://github.com/akunbeben/fortify-role/blob/master/LICENSE)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/akunbeben/fortify-role/tests?style=for-the-badge)](https://github.com/akunbeben/fortify-role)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/akunbeben/fortify-role?label=version&style=for-the-badge)](https://github.com/akunbeben/fortify-role)

## Requirement
- Laravel ^8.x
- Laravel/Fortify ^1.x

## Installation
I recommended you to install this package only on a fresh project.

Install the package using composer
```
composer require akunbeben/fortify-role
```

## Usage
Before continuing the process, please make sure the `FortifyServiceProvider.php` is registered in `config/app.php`. If it's already registered, you can skip this.

```php
'providers' => [
...
App\Providers\FortifyServiceProvider::class,
],
```
Then publish the package's vendor files. It's need `--force` because it will replace the `RedirectIfAuthenticated` middleware.
```
php artisan vendor:publish --provider="Akunbeben\FortifyRole\FortifyRoleServiceProvider" --force
```
And then, add `HasRole` traits to your `User` model.
```php
['auth', 'role:admin']], function () {

});

Route::group(['middleware' => ['auth', 'role:user']], function () {

});
```

### Notes
- On the roles table migration file, there is a default value to assign the role to registered user. You can adjust it to your need.