How to use laravel default authentication in backpack - laravel

What I am doing:
I am doing a project in laravel using Backpack. In my project, there are two views. i.e. Admin view and Student view. Admin view is created using Backpack and the student view is created using auth. Admin uses the backpack's login and registration forms and routes while the student uses Laravel's auth's login and registration forms.
What I want to do:
So What I want is that I want to use Laravel's login forms and routes for logging into backpack dashboard as well and completely remove login and registration forms and routes of Backpack.
I am a newbie in laravel so maybe my question may be a little novice.
How can I do that? Kindly guide me in this regard.

You can disable all of Backpack's auth routes in config/backpack/base.php:
// Set this to false if you would like to use your own AuthController and PasswordController
// (you then need to setup your auth routes manually in your routes.php file)
'setup_auth_routes' => false,
And make Backpack use the default guard everywhere by setting this to null in the same file:
// The guard that protects the Backpack admin panel.
// If null, the config.auth.defaults.guard value will be used.
'guard' => null,
You can then use your custom auth to login both users and admins.
But make sure you differentiate between users and admins in your app\Http\Middleware\CheckIfAdmin, you wouldn't want your students to have access to your admin panel.

Related

Enable a readonly view to Laravel Nova without login

I'm using Laravel Nova to make a collaborative Wiki for songs. I would like an unauthenticated user be able to see the songs, but not collaborate. He would be able to collaborate only after registering a new account.
I tried to comment the Laravel\Nova\Http\Middleware\Authenticate middleware, in file 'web' middleware in config/nova.php.
Now, it still works for my superAdmin, and my simple user, but for the unauthenticated user, it can reach nova dashboard without login, but there is no more items in left menus. The only way to make them appear is to remove the custom policies I have defined for my resources.
Why is it happening, and what should I do to

Passport authentication with multiple user models

I'm using Laravel 7.3 as backend (admin panel) and API, and I have a multiple Nuxt websites authenticating with Laravel Passport. So I have the default User model for admin panel users and other user models, one for each Nuxt website. But Laravel Passport seems to be only working with the default User model.
How should I authenticate the users of the different Nuxt websites in such configuration ?
There are 4 functions that exist on the Passport Facade:
Passport::useClientModel(Client::class);
Passport::useTokenModel(TokenModel::class);
Passport::useAuthCodeModel(AuthCode::class);
Passport::usePersonalAccessClientModel(PersonalAccessClient::class);
You need to implement logic that ties your frontend model relationship to your backend, and instantiate the correct model for the given passport methods inside of a service provider.

how to make frontend user login and admin login in laravel

I have requirement of user login in frontend and also i need to make admin panel in laravel, i have create custom user table for frontend user because its have multiple other fields, in this case if i use laravel php artisan make:auth then it will create laravel login that i can redirect to different route(different admin folder in views) but if i use laravel default login and add frontend user custom fields in db table then how can i use this direction? My main question is, i need to use laravel make:auth db table for front end user and administrator user with different role or i need to make two different tables for both admin and frontuser login?
You can use the package below to do this.
The following package contains the Role&Permission - registration and login.
If your problem is not resolved, I can help you more.

how to create custom login registration application laravel without using auth ,by creating own controller model

I am new in laravel. I have installed laravel 5.4. I have installed laravel inbuild auth. but I want to create own login & registration with two user type . one is customer and another is for admin with different functionalities for two user types. using custom controller,model route without using auth.

User and admin role in laravel 5.3

In my laravel project, I want some admin and user role. I want to make user login in different routes after login. And also for admin also. How should I do it?
You should first make 3 table in your database; user, role and user_role. user_role table has many to many relationship. Then you will make a middleware that checks your role checks when login. In your route, you use that middleware in login's post.
See details about middle ware in laravel 5.3 documentation.
https://www.laravel.com/docs/5.3/middleware
You can try laravel 5.3 boilerplate. It comes with a full featured access control system out of the box with an easy to learn API and is built on a Twitter Bootstrap foundation with a front and backend architecture.

Resources