A
A
Alexander Kovalchuk2016-05-18 16:54:13
Laravel
Alexander Kovalchuk, 2016-05-18 16:54:13

How to change authentication in SleepingOwl4?

In the old version, I changed it like this:
config/admin.php file

'auth'                    => [
    'model' => '\SleepingOwl\AdminAuth\Entities\Administrator',
    'rules' => [
      'username' => 'required',
      'password' => 'required',
    ]
  ],

on the
'auth'                    => [
    'model' => \App\User::class,
    'rules' => [
      'email' => 'required',
      'password' => 'required',
    ]
  ],

'middleware' => ['admin.auth'],
by
'middleware' => ['isadmin'],
pre-registering in the middleware
if (Sentinel::guest()) return redirect('/');
if(Sentinel::inRole('user')) return $next($request);
return Redirect::back();

and it worked, but now the settings are taken from config/auth.php
'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],

And now it does not work (when you try to go to the admin panel, it returns to the main one)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Buchnev, 2016-05-19
@mamut

Hello, well, actually, these are no longer admin problems, but more Laravel problems, I would even say not problems, but changes.
The documentation describes the process of changing the authorization algorithm:
In short, in Laravel 5.2, so-called guards appeared, which allow you to implement several authorization algorithms and use them in parallel, as well as choose the default authorization guard.

'defaults' => [
     'guard'     => 'sentinel', // Используемый по умолчанию
      ....
],
...
'guards' => [
     ...
     'sentinel' => [
          'driver'   => 'session',
          'provider' => 'sentinel',
     ],
],
...
'providers' => [
     'sentinel'  => [
          'driver' => 'sentinel',
          'model' => App\User::class,
          'options' => [
                ....
          ],
     ],
],

Auth::extend('sentinel', function($app, $name, array $config) {
      ...
});

Those. we create our provider for authorization, make it the default guard.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question