I'd like to make authentication for admin and user using the laravel 5.2 auth api, I've a users table in which I've define ENUM type role field for user and admin so I need to use only table but different views and routes for admin and user login.
I've successfully create a user auth by using following command.
php artisan make:auth
but I can't understand how to implement auth for admin.
before you answer keep in mind there is only one users table which have role field and different views for admin and user login. After successfully login user will redirect to home page and admin should redirect to admin/dashboard.
Thanks
You Can use https://github.com/romanbican/roles package ...
if ($user->is('admin')) { // you can pass an id or slug
// or alternatively $user->hasRole('admin')
}
Related
I'm using ApostropheCMS. I want to add users authentication to my project. How can I do this? The users should be created in the same way I created admin user? (via /login page and apostrophe-users module).
I want to create a custom form for both login and registration. Then I want to check if the user is log in and if so, I want an user profile for them.
There's a module you can install to add a signup form: https://github.com/apostrophecms/apostrophe-signup
How can I ensure that when users enter localhost/Admin they are redirected to Admin/Account/Login instead of Account/Login using Asp.net core identity? I am using default template for authorization in asp.net core. Then I want to make sure that only users with role Administrator can login from there. How can I do that?
You can't. When user is not authenticated, how can the system know if they are admin or not?
Instead of 2 login pages - have a single login page, but upon successful credentials checks redirect users to different pages depending if they are admin or not.
I used liferay 5.2 and I can integrate ldap correctly with liferay and I activated ldap in login.
and I arrived to import only users from ldap wich exists in my groups using this configuration :
my problem now is when I try to login in liferay
it checks user if exist or not in all locations in ldap
I want in login state to check user if exist or not only in my specifics group which is exist in my configuration.
meaning in login state check user only in :
testGroup1 and testGroup2 and not in all locations in ldap
I want to use active admin for my app but i want to auth users by ldap server without needing to create database for users. Is this even possible?
Now my app use basic http auth which i dont like a lot
I'm looking for solution that will help me to auth user for actve admin only by piece of code like this:
ldap = Net::LDAP.new :host => 'ip'
ldap.auth "uid=#{name.split('#').first},ou=Users,dc=huzar,dc=pl",password
ldap.bind
I have the following scenario:
Rails app with User and Admin devise models, so I have two scopes.
Created on ember app on router:
Router.map(function() {
this.route('panel', function() {
this.route('login');
this.route('logout');
});
this.route('admin', function() {
this.route('login');
this.route('logout');
});
});
I'm using jj-abrams branch once my app is Ember 2.0
Both authenticating on /users/sign_in and /admins/sign_in
I followed steps on https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-devise#server-side-setup and authentication is working.
Ember is hitting the right urls after creating authenticators and adapters, but the problem is that ESA just have one session service. Once user or admin is logged in session.isAuthenticated is true and I don't know which scopes are logged in.
Which is the best way to proceed:
Add a role on user reply and set on session
Create a new session for admin user
I solved this problema creating 3 authenticators for each scope, and I handle each one.
It is a particular solution once I don't use other authenticators (OAuth2), but now I can check if authenticator:user, authenticator:admin, authenticator:manager was used on to login.
I have created checks on routes, so user can only access his panel, admin can access user and admin panel, and manager can access the whole system.
I've posted the ember and the API on github:
https://github.com/fernandes/ember-auth-web for the ember
https://github.com/fernandes/ember-auth-api for the devise api
ps: I think would be better to create sessions for each scope, but I don't know how to do it (and if its better or not), in this solution you can login one scope at once (not like devise on rails you can log with many scopes at once).