login as a user and admin at the same time in laravel - laravel

I am working on a laravel project in which from ADMIN panel I can log in in the user module, but when I want to go back from the browser the admin panel is not working means admin is logout. is there any method in which I can log in in both module admin and user.

If you log in as one user, you log out as the other.
I see 2 possibilities:
1) Make 2 user tables, with separate login/logout/etc. one for your frontend users, one for your admin panel.
The advantage here is that your regular users will never be able to login as an admin, because they don't exist in that table.
2) Separate your frontend and admin panel into 2 different projects. You can link them to the same database. Put the admin panel on a subsite admin.my-project.com.
The advantage here is that you seperate your logic between 2 projects, each focused on different functionality, with their own styling, layout and most important for your example: authentication.

Use an incognito browser window for your admin tasks, which will enable you to be logged in to the same app twice.

You could solve your problem with two possible ways that laravel provide and you could google about "laravel multi auth example".
Multiple authentications using "middleware"
Multiple authentications using auth "guards"
Here are two articles will help you to understand and show you the implement with an example:
Laravel 6 Multi Auth (Authentication) Tutorial
How to use multiple authentication guards in a Laravel app

Related

How to use Laravel backpack for non admin user

In my system, there are tow types of users.
Admin.
Regular.
For admin I am using Laravel backpack. But, I also want the backpack's features for non admin panel also.
What's the way?
Usually people use Roles/Permissions to handle that.
There is a Backpack addon that will give you a kick start with cruds for user/permission/role using the Spatie Laravel Permission under the hood: https://github.com/Laravel-Backpack/PermissionManager
Then you can show some bits of your app to some users, hide some fields/columns from others etc.
Just remember that users will be authenticating using backpack guard, so you should use backpack_user()->hasRole(), or see the advanced configuration of the package in ReadMe.
Cheers

How to create your own module based on laravel's authentication?

I am new to laravel and currently i am learning and experimenting on my old php based mini-project conecpt ,i have successfully created the user registration and user login with some features for users,but i am confused how do i create a admin module and provide admin privilege's along with one more sub module (moderator).
I have completed website module,it works fine but i am confused how do i give the following functionalities.
how do i add admin module
admin can access user information
only admin can add moderator
any suggestions would be helpful,
Thank you.
I think what you are trying to do is make some routes only accessible by an admin or moderator?
Make a custom middleware so only if a user has a sufficient role level they can acces the given route.
https://laravel.com/docs/5.6/middleware#defining-middleware
You could have a moderator middleware that checks if a user has role 1 or higher, and a admin middleware that checks if a user has role 2.
i hope this is somewhat what you are searching for.

How do I get CodeIgniter sessions to work accross multiple applications?

I use two different applications in my CI installation. The first is called "admin"... obviously an admin panel. The second is "frontend" where everything else is. I use the same database for each of the apps and the same member tables, both for admin authentication and member auth. The problem is, since the CI session class doesn't use native PHP sessions, the session only works in the application that it is set in(which makes sense)... for example, if a user that is indeed an admin logs into the system through the frontend app and then clicks the link to the admin app, they are required to login again. If they have the "Remember Me" option selected across when they login to both apps, this obviously isn't a problem.
How would I fix this? Or do you guys think it's better to have them login to the admin app again, just to validate their admin status again?
Thanks for your time.
You could use the native php session instead. There's a class which you can just copy paste, and you'll not have to change any of the rest of your code.

Single sign on for Joomla admin and frontend

Is it possible to implement single signon for Joomla 1.5 backend and frontend. I find it kind of redundant that when the admin for instance is logged in at the backend and needs to do some user function on the frontend has to login again. Is there a way of implementing a single signon?
Joomla! is implemented as two separate applications the front-end initiated from /index.php and the back-end administration from /administrator/index.php as such they have separate user sessions and states.
The separation is a standard security approach, while you could write your own mod_login to do this I wouldn't advise it unless you're very clear on what you're doing.
Having said that, there are 255 Joomla! extensions in the Access & Security ——> Site Access section dealing with logins. Have you tried looking there?
This joomla extension can do that.
http://www.everlive.net/joomla-extensions/15-joomla-admin-from-frontend.html
Just login to frontend as an admin user. You will be logged-in automatically to backend. Further it gives you useful direct links for various backend operations like article add, edit, publish, unpublish etc. Same kind of links are available for modules and menu items.

Devise: How to create a private admin role?

I have a simple Rails 3 blog app that needs an admin user so I can restrict creating and editing blog entries to the admin. I've used devise before, but only for users that are public and can be created by anyone. I don't want the ability to create an admin to be publicly accessible. How should I configure devise to be able to have an admin user?
Update:
After creating an Admin model, you might want to know how to create an admin that can log in (since you won't be able to register them on the front-end).
Have a look at the HOWTO in Github. There are basically two options:
Create a separate admin model
Add a admin attribute to the existing user model
I personally prefer option 1 for larger applications which tend to have different views for admins and normal users. For smaller apps I would recommend option 2.

Resources