Support the ongoing development of Laravel.io →
Authentication Authorization
Last updated by @tvbeek 1 year ago.
0
moderator

Hello @damogallagher

This is a big class :)

Do you upgrade in steps (so 5.2 -> 5.3 -> 5.4 >>>> 9) or are you going directly from 5.2 to 9? My personal experience is that it is more doable to do it in steps.

Do you get any errors for this class?

ps. I have updated your post to get the code more readable.

0

Hi @tvbeek

Thank you for getting back to me. Yes I went back through the notes and have come to the following.

Replace the following import use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; with use Illuminate\Foundation\Auth\AuthenticatesUsers;

My errors are narrowed to the following lines now. I get an error that AuthController::getCredentials does not exist.

For this line and other lines that refer to the guards, do you happen to know what the equivalent in Laravel 9 would be?

$credentials = $this->getCredentials($request);
            if (Auth::guard('admin')->attempt($credentials)) {

                // Check valid admin user and record last login date
                $auth = Auth::guard('admin')->user();

                $urls = AdminPrivilege::select('url')->where('group', $auth->group)->get();

                $result = array();
                foreach($urls as $v){
                    array_push($result, $v->url);
                }

                // Put group, url info into Session for Admin Privilege
                session([
                    'group'     => $auth->group,
                    'url'       => $result
                ]);

                $auth->confirmLogin($auth->admin_id);`

Or do you happen to any links to sample applications that have authentication setup for different user types? (e.g. standard users, admins etc)

dbdxwb liked this reply

1
moderator

I see that the function exist in Laravel 5.2: https://github.com/laravel/framework/blob/5.2/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php#L154

I think the most easy way is to recreate the (working of) that function in your controller.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.