lundi 28 décembre 2015

Route Restriction base on Auth User Type

I have 3 kind of users

  • admin-super
  • admin
  • admin-readonly

I've created 3 Middlewares in /app/Http/Middleware I named them

  • AdminSuperMiddleware.php
  • AdminMiddleware.php
  • AdminReadonlyMiddleware.php

I've already registered them in /app/Http/Kernel.php as followed

    'admin'          => 'App\Http\Middleware\AdminMiddleware',
    'admin-super'    => 'App\Http\Middleware\AdminSuperMiddleware',
    'admin-readonly' => 'App\Http\Middleware\AdminReadOnlyMiddleware',


I've tried calling them in my routes.php

    $router->group(['middleware' => ['auth', 'admin-super'] ], function() {
        Route::get('account','AccountController@index');
        Route::post('account/store','AccountController@store');
        Route::post('/view-profile/logo/update', 'ProfileController@updateLogo');
    });

    $router->group(['middleware' => ['auth', 'admin'] ], function() {
        Route::get('account','AccountController@index');
        Route::post('account/store','AccountController@store');
    });

    $router->group(['middleware' => ['auth', 'admin-readonly'] ], function() {
        Route::get('account','AccountController@index');
    });


Result

When I log-in as user type == admin and go to :

http://localhost:8888/account

I kept getting 404.

Did I missing anything ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Ptv9qq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire