I am using restful_authentication in combination with role_requirment.
At the beginning of the controllers that I want to have login control
over, I include
require_role "user"
require_role "admin"
For instance. If I login as either of the two roles then call a
controller it works fine. However if I do not login at all and simply
call a controller, it let's me right in. It doesn't restrict access
whatsoever. No redirect to a login page or nothing.
How do I restrict access if no user is logged in at all?
1. You have these roles defined in the roles table? and;
2. There is an entry for row_id and user_id in your roles_users table?
For example,
If admin user has a user_id of 1 in users table and your roles table
defines the "admin" role with a role_id = 1 then you must have a row
in roles_users table corresponding to this combination:
I had broken r_a#before_filter :login_required by tweaking the source
to make some tests pass. That change had also altered the way the
r_r#require_role was working.
I changed the code back, and now require_role "user" & require_role
"admin" do as they should without having to use
before_filter :login_required as well.
1. You have these roles defined in the roles table? and;
2. There is an entry for row_id and user_id in your roles_users table?
For example,
If admin user has a user_id of 1 in users table and your roles table
defines the "admin" role with a role_id = 1 then you must have a row
in roles_users table corresponding to this combination:
role_id = 1, user_id = 1
Check if you have done this.
Bharat
Sorry for resurrecting an old thread, but this situation describes
exactly the situation I have set up. Yet I can't get the user to
authenticate as an administrator.
I have a single user who I have granted admin rights, in the
admins_users table:
However, I can't seem to discover why the user is denied access.
Within the user model there is a method called has_role? which compares
all names in the admin table versus "admin". If it matches then the
user is granted admin access. I modified has_role? by passing the
user's id in as well (lib/role_requirement_system.rb line 100). It now
compares the user's id vs the ids in the admin table. A match grants
admin access.