You can't create two instances of Auth in the same db without renaming all
the Auth tables (otherwise, both instances will simply be accessing the
same set of tables). Another problem is that upon login, Auth stores the
user record and login information in session.auth -- so if you login with
one Auth, you'll get a session.auth, which will make the other Auth think
you are logged in to that one as well. Basically, you'll have to stick with
one Auth per app. For alternative approaches,
see https://groups.google.com/d/msg/web2py/4LfJ9TotypE/GcmKXw0NgX4J.
Anthony
On Sunday, June 9, 2013 11:10:41 PM UTC-4, André Kablu wrote:
>
> I build a application that have 2 AUTH objects...
>
> I use 1 Auth object for the main site functionality that contains many
> levels of users (using default tablename settings for auth)
>
> and I made 1 more Auth table to use as SITE ADMIN, just to control main
> site admin functions on a separated controller...
>
> so I did:
>
> auth_admin = Auth(db)
> auth_admin.settings.table_user_name = 'auth_admin_user'
> auth_admin.settings.table_group_name = 'auth_admin_group'
> auth_admin.settings.table_membership_name = 'auth_admin_membership'
> auth_admin.settings.table_permission_name = 'auth_admin_permission'
> auth_admin.settings.table_event_name = 'auth_admin_event'
> auth_admin.define_tables(username=False, signature=False)
> auth_admin.settings.actions_disabled.append('register')
>
> auth = Auth(db)
> auth.define_tables(username=False, signature=False)
>
>
>
>
> this is working fine with main auth
>
> but when I created the ADMIN controller with main site admin functions
> (using auth_admin), the requires_login decorator is not working:
>
> this is the index code of the ADMIN controller:
>
> @auth_admin.requires_login()
> def index():
> return dict(message='Admin Panel')
>
>
> however the @auth_admin.requires_login is enabling auth users to login...
> and not just auth_admin users
>
> someone can help to know what am I doing wrong?
>
> Thanks!
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.