Skip to content
Open

3.0 #129

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
],
"require": {
"php": ">=5.5.0",
"hesto/core": "1.0.*"
"hesto/core": "2.0.*"
},
"autoload": {
"psr-4": {
"Hesto\\MultiAuth\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Hesto\\MultiAuth\\MultiAuthServiceProvider"
]
}
}
}
73 changes: 5 additions & 68 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

## What it does?
With one simple command you can setup multi auth for your Laravel project. The package installs:

- Model
- Migration
- Controllers
Expand All @@ -39,22 +40,13 @@ With one simple command you can setup multi auth for your Laravel project. The p

### Step 1: Install Through Composer

```
composer require hesto/multi-auth
```shell
composer require hesto/multi-auth --dev
```

### Step 2: Add the Service Provider (only for laravel lower than 5.5)

You'll only want to use these package for local development, so you don't want to update the production `providers` array in `config/app.php`. Instead, add the provider in `app/Providers/AppServiceProvider.php`, like so:

```php
public function register()
{
if ($this->app->environment() == 'local') {
$this->app->register('Hesto\MultiAuth\MultiAuthServiceProvider');
}
}
```
Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider. You'll only want to use these package for local development, so this package will be included in require-dev section. When your site is deployed to production you will remove dev packages.

### Step 3: Install Multi-Auth files in your project

Expand Down Expand Up @@ -165,63 +157,8 @@ public function logoutToPath() {
- Routes file for given guard

- resources/views/{guard}/
- Views for given guard

## Changelog

### Note: Never install configurations with same guard again after installed new version of package. So if you already installed your `admin` guard, don't install it again after you update package to latest version.

### v1.0.7
- changed {guard}/logout route method from `get` to `post`
- added `{guard}.guest` middleware to redirect from login page if user is already logged in
- added home view after login

### v1.0.6
- added `auth:{guard}` middleware to `app\Providers\RouteServiceProvider.php`. If you have installed multi-auth guard with old version add middleware manually:
```php
Route::group([
'middleware' => ['web', 'admin', 'auth:admin'], //you need to add the last middleware to array to fix it (version < v.1.0.6)
'prefix' => 'admin',
'as' => 'admin.',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/admin.php');
});
```

### v1.0.5
- composer.json fix

### v1.0.4
- added name and prefix to route group configuration in `RouteServiceProvider`

```php
Route::group([
'prefix' => 'admin', //if you have older version of package ( < v1.0.4) add this line manually,
'as' => 'admin.', //if you have older version of package ( < v1.0.4) add this line manually (the DOT at the end is important),
'middleware' => ['web', 'admin'],
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/admin.php');
});
```

- Now you will be able to name your routes without adding guard's name to route name in your `routes/{guard}.php` and your routes will be named (its important)

```php
//New way
Route::get('/home', function () { // <- no {guard} prefix and it has proper name (admin.home)
//content
})->name('home'); // http://your-project/admin/home

//Old way
Route::get('/admin/home', function () { // <- with {guard} prefix
//content
})->name('admin.home'); // http://your-project/admin/home
```

### v1.0.3
- changed deafult auth's layout name from `app.blade.php` to `auth.blade.php`
- Views for given guard

## Support on Beerpay
Hey dude! Help me out for a couple of :beers:!
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/AuthViewsInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AuthViewsInstallCommand extends InstallAndReplaceCommand
*
* @return bool|null
*/
public function fire()
public function handle()
{
$this->installViews();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/MultiAuthInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MultiAuthInstallCommand extends InstallAndReplaceCommand
*
* @return bool|null
*/
public function fire()
public function handle()
{
if ($this->option('lucid') && ! $this->getParsedServiceInput()) {
$this->error('You must pass a Service name with the `--lucid` option.');
Expand Down
13 changes: 5 additions & 8 deletions src/stubs/routes/map-method.stub
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
*/
protected function map{{singularClass}}Routes()
{
Route::group([
'middleware' => ['web', '{{singularSnake}}', 'auth:{{singularSnake}}'],
'prefix' => '{{singularSlug}}',
'as' => '{{singularSlug}}.',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/{{singularSlug}}.php');
});
Route::prefix('{{singularSlug}}')
->middleware(['web', '{{singularSnake}}', 'auth:{{singularSnake}}'])
->namespace($this->namespace)
->name('{{singularSlug}}.')
->group(base_path('routes/{{singularSlug}}.php'));
}

18 changes: 9 additions & 9 deletions src/stubs/routes/web.stub
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

Route::group(['prefix' => '{{singularSlug}}'], function () {
Route::get('/login', '{{singularClass}}Auth\LoginController@showLoginForm')->name('login');
Route::post('/login', '{{singularClass}}Auth\LoginController@login');
Route::post('/logout', '{{singularClass}}Auth\LoginController@logout')->name('logout');
Route::get('/login', '{{singularClass}}Auth\LoginController@showLoginForm')->name('login');
Route::post('/login', '{{singularClass}}Auth\LoginController@login');
Route::post('/logout', '{{singularClass}}Auth\LoginController@logout')->name('logout');

Route::get('/register', '{{singularClass}}Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('/register', '{{singularClass}}Auth\RegisterController@register');
Route::get('/register', '{{singularClass}}Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('/register', '{{singularClass}}Auth\RegisterController@register');

Route::post('/password/email', '{{singularClass}}Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.request');
Route::post('/password/reset', '{{singularClass}}Auth\ResetPasswordController@reset')->name('password.email');
Route::get('/password/reset', '{{singularClass}}Auth\ForgotPasswordController@showLinkRequestForm')->name('password.reset');
Route::get('/password/reset/{token}', '{{singularClass}}Auth\ResetPasswordController@showResetForm');
Route::post('/password/email', '{{singularClass}}Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.request');
Route::post('/password/reset', '{{singularClass}}Auth\ResetPasswordController@reset')->name('password.email');
Route::get('/password/reset', '{{singularClass}}Auth\ForgotPasswordController@showLinkRequestForm')->name('password.reset');
Route::get('/password/reset/{token}', '{{singularClass}}Auth\ResetPasswordController@showResetForm');
});
2 changes: 1 addition & 1 deletion src/stubs/views/auth/login.blade.stub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('{{singularSlug}}.layout.auth')
@extends('{{singularSlug}}.layouts.auth')

@section('content')
<div class="container">
Expand Down
2 changes: 1 addition & 1 deletion src/stubs/views/auth/passwords/email.blade.stub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('{{singularSlug}}.layout.auth')
@extends('{{singularSlug}}.layouts.auth')

<!-- Main Content -->
@section('content')
Expand Down
2 changes: 1 addition & 1 deletion src/stubs/views/auth/passwords/reset.blade.stub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('{{singularSlug}}.layout.auth')
@extends('{{singularSlug}}.layouts.auth')

@section('content')
<div class="container">
Expand Down
2 changes: 1 addition & 1 deletion src/stubs/views/auth/register.blade.stub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('{{singularSlug}}.layout.auth')
@extends('{{singularSlug}}.layouts.auth')

@section('content')
<div class="container">
Expand Down
2 changes: 1 addition & 1 deletion src/stubs/views/home.blade.stub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('{{singularSlug}}.layout.auth')
@extends('{{singularSlug}}.layouts.auth')

@section('content')
<div class="container">
Expand Down