3

I'm new to Laravel and I'm developing an application with User, Roles ans Permission. For this I'm using Zizaco/Entrust. I'm almost done with all of the steps but I'm not able to show the custom page for 403. My code are as follows :

Permission : role-list
Role : Manager

'role-list' is assigned to 'manager' role and then 'manager' role is assiged to 'ABC' user.

In my app\kernel file id added these middlewares :

protected $routeMiddleware = [
        'auth' => \Eybos\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
        'guest' => \Eybos\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
        'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
        'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,
    ];

In my routes file :

Route::get( 'backend/roles', [ 'as' => 'backend.roles.index', 'uses' => 'Backend\RoleController@index', 'middleware' => ['permission:role-list|role-create|role-edit|role-delete']] );

And then created a file : resources/views/errors/403.blade.php

@extends('layouts.backend')

@section('content')
    <h1>You don't have permission.</h1>
@endsection

But when I try to access the page I get this error :

FatalErrorException in Decorator.php line 80:
Trying to clone an uncloneable object of class Symfony\Component\HttpKernel\Exception\HttpException
4

1 に答える 1

0

これが正しい答えかどうかはわかりませんが...

Lewis->presenter->src->Decorator.php に移動します。

80 行目に「$object = clone $object;」と表示されます。

その行をコメントアウトすると、アクセス許可で機能し始めるはずです。

于 2016-10-16T23:19:54.033 に答える