(web2py newbie here) - I've got user authentication working ok, but I'd like to be able to scope the auth_users inside an account. My plan is to have accounts identified by subdomains, e.g. account_one.example.com, and then inside that the users can login (a la Basecamp).
I've got the following working to get the account model based on the subdomain, redirecting to an "account not found" page: def requires_account(f): subdomain = request.env.http_host.split('.')[:-2].pop() account = db(db.account.subdomain==subdomain).select().first() if not account: redirect(URL('default', 'account_not_found')) return f @requires_account @auth.requires_login def index(): ... However, I'm a bit stumped as to how to restrict the login to only those users in that account. I've added an account_id field to the auth_users table, but I'm not sure how to proceed - I think ideally I'd like to extend / override the requires_login method so it uses the account but I can't work out how to do it - any help (or suggestions of a better way to do it!) are greatly appreciated! Many thanks Dave