Welcome Guest, Not a member yet? Register   Sign In
Shield wrong redirect
#1

(This post was last modified: 12-19-2023, 01:03 PM by pippuccio76.)

Hi , i installed shield , i want redirect based on type of user :
in config Auth :

Code:
    /**
    * Returns the URL that a user should be redirected
    * to after a successful login.
    */
    public function loginRedirect(): string
    {
        $session = session();
        //$url    = $session->getTempdata('beforeLoginUrl') ?? setting('Auth.redirects')['login'];

        //return $this->getUrl($url);


        if (auth()->user()->can('admin.access')) {
            return '/admin/test';
        }

        if (auth()->user()->can('user.access')) {
            return '/user/test';
        }

        $url = setting('Auth.redirects')['login'];

        return $this->getUrl($url);
    }

[CODE]
Authgroup:
[CODE]
    /**
    * --------------------------------------------------------------------
    * Permissions Matrix
    * --------------------------------------------------------------------
    * Maps permissions to groups.
    *
    * This defines group-level permissions.
    */
    public array $matrix = [
        'superadmin' => [
            'admin.*',
            'users.*',
            'beta.*',
        ],
        'admin' => [
            'admin.access',
            'users.create',
            'users.edit',
            'users.delete',
            'beta.access',
        ],
        'developer' => [
            'admin.access',
            'admin.settings',
            'users.create',
            'users.edit',
            'beta.access',
        ],
        'user' => [
            'users.access',

        ],
        'beta' => [
            'beta.access',
        ],
    ];
[/CODE]
this is the route :
Code:
$routes->group('admin', ['filter' => 'adminFiltersAuth'], function($routes) {


    $routes->get('test','Admin::test');


});


$routes->group('user', ['filter' => 'userFiltersAuth'], function($routes) {

    $routes->get('test','User::test');

});
When i log admin user the system redirect on admin/test , when i log user the system redirect to hom/index  .
What's my error ?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB