I am developing a package for Laravel 4 I need to add some authentication and authorization to this package, I need to use a table other than users table in this case: "admins"
The laravel application by default is looking for the table Users and check if the username and password exist there, I need my app to take advantage of default Authentication of Laravel (which looks the users table), but I also need to keep away the data of admins from the normal users and have authentication for another table as well (in 2 different tables).
Question:
How should I solve this issue? do I have to override the settings of auth.php file or can I extend this authentication in my own package so it work alongside with auth of Laravel 4?
To change that open app/config/auth.php
change 'table' => 'users' into 'table' => 'admins'
and also change 'model' => 'Admin'
Related
I've created a custom authentication plugin, which allows me to login to Joomla with my own user Table. So at this point, the authentication to the system is working and a user object will be created. All information until logout can be seen with $user = JFactory::getUser();.
My problem is, that after login, my menue won't be shown. It seems, that my template is not loaded. If I manually change the userid to one of the registered users in Joomla (only the id will be changed, no other values of the user object), the template will be loaded and the menue will be shown.
What do I have to do to get this to work? What is missing, or what do I wrong?
Because of the Joomla rights system, Joomla calls getAuthorisedViewLevels() and getGroupsByUser() in libraries/joomla/access/access.phpin and looks up the groups from user_usergroup_map.
Because it is an external user authentication, there is no user_usergroup mapping.
Therfore I built a work around. During the login procedure I added a function to my plugin which sets the user_id in the user_usergroup_map table for temporary using.
In case of logging out, the entry in the user_usergroup_map table will be removed.
I am a new in Yii framework, I just setup an application and separate front-end & Back-end part. Both User can register / log in properly. Now I want to login different user from front-end site.
Example : Front-End user are tow types
1. Customer
2. Merchant
I want to set different role of theme. How to possible it, Please share with me.
You will probably need to use Yii's RBAC. In order to implement and use RBAC in yii you need to follow the following steps:
1-configure main.php which is located at '/path/to/yourApp/protected/config/main.php'
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'db', //your database config name
),
2-import yii's rbac database scheme into your database. You can find it under /path/to/yii/framework/web/auth/ directory
3-add your operations. Operations such as 'VIEW_POST' or 'EDIT_POST':
$auth=Yii::app()->authManager;
$auth->createOperation('VIEW_POST','view a post');
$auth->createOperation('EDIT_POST','edit a post');
4-create your roles. For example in your case you will have two roles. First Customer and second Merchant.
$role=$auth->createRole('CUSTOMER');
5- Assign operations to your roles:
$role->addChild('VIEW_POST');
6- All done! You can restrict the access like below:
if(Yii::app()->user->checkAccess('VIEW_POST'))
{
//user has access to view a post
}else{
//logged in user has no access to view a post
}
You can also check access with role like below:
if(Yii::app()->user->checkAccess('CUSTOMER')) {}
In order to assign a role to a user use the assign method:
$auth->assign('CUSTOMER','USERNAME | USER ID'); //user will hold the CUSTOMER ROLE
It might also be noted that, I assumed that you have implemented your authentication class. You can find more about Yii's RBAC and authentication in the following link which is Yii's official document:
Yii Authentication and Authorization
I am new to ruby on rails
I am developing application which have four users Patient,Doctor,Nurse and Admin i have created patient user using devise now i want to create Admin user which will be used to do all administrative tasks like display all registered patients, etc..
so how can i add the new user to rails application. Do i need to create a new controllers for them
I tried to create the new user by referring this web page
http://rubyonrailshelp.wordpress.com/2014/01/03/creating-user-and-admin-model-using-devise-rails/
but it creates new files and update some existing files when i run this command
$rails generate devise:views
is it there feature or something went wrong i don't have an idea ?
please help
You have to create one devise user table with have one column as role_name:string which will save the your role name (Patient,Doctor,Nurse, Admin) and for admin it should be 'admin'...
And if its one in app then you will create by seed file (app/db/seed.rb)
As User.create(email: , password: , roll_name: 'admin' ) then
rake db:seed
I have an Iron-Speed application generated from my database and wish to add password protection to all of the pages.
I already have a table in my database with usernames and passwords, how do I apply this to my Iron-Speed pages?
Yes you just required to have 3 tables in your Database :
Users
Roles
UserRoles (Relation between both)
It also create login automatically
and you can also get Users Info by Get methods of :
BaseClasses.Utils.SecurityControls.Get___
from any page
After some investigation, I found that Iron-Speed (What a program!) already has a wizard built in for security purposes, such as password protection.
By going to Tools --> Role-Based Security Wizard, everything can bet set up by linking it to the relevant fields in the 'User' table in your database.
Hi i have 3 Yii based systems, something like:
sys1.domain.com
sys2.domain.com
sys3.domain.com
now, this 3 systems share the same database, same users, and other entities... and of course the 3 yii auth tables.
now my question is, when configuring auth, how do i separate auth rules for each system?
i'm using Yii extension "rights" to manage roles, if this is of any help.
As you have single DB for three systems sys1, sys2 and sys3 and you would like only auth table diffent, you can add three auth tables auth_sys3, auth_sys2, auth_sys1 and in config file of each system write configuration or at global place write php logic to make alias of auth_sys1,auth_sys2,auth_sys3 as auth so you dont requrie to make any changes in internal code to call auth.