So I have a somewhat unique situation where multiple different users will
be creating separate accounts with unique usernames, using the SAME email
address. I figured I could make this happen by using custom auth tables
like this:
## Manually set up Auth tables so you can have non-unique emails
db.define_table(
auth.settings.table_user_name,
Field('username', length=32, default=''),
Field('first_name', length=128, default=''),
Field('last_initial', length=1, default=''),
Field('email', length=128, default=''), # required
Field('password', 'password', length=512, # required
readable=False, label='Password'),
Field('registration_key', length=512, # required
writable=False, readable=False, default=''),
Field('reset_password_key', length=512, # required
writable=False, readable=False, default=''),
Field('registration_id', length=512, # required
writable=False, readable=False, default=''))
## do not forget validators
custom_auth_table = db[auth.settings.table_user_name] # get the
custom_auth_table
custom_auth_table.first_name.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.last_initial.requires =
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.password.requires = [CRYPT()]
custom_auth_table.email.requires =
[IS_EMAIL(error_message=auth.messages.invalid_email)]
custom_auth_table.username.requires = IS_NOT_IN_DB(db,
custom_auth_table.username)
auth.settings.table_user = custom_auth_table # tell auth to use
custom_auth_table
# Define auth tables
auth.define_tables(username=True, signature=False)
There are two issues with this approach.
First, "forgot password" asks for an email still and resets the first
account in the table with that user name. Is there a way to reset based on
username built in to web2py? I couldn't seem to find anything in the
documentation so i'm thinking no unfortunately...
Second, and less vital, is the "forgot username" functionality emails the
first username in the table linked to the entered email only. Ideally you
would email the names and usernames of all accounts linked to the email
address.
Is there any way I could enable the described desired functionality? Could
I somehow extend the existing login functionality without breaking the
ability to update my web2py instance (basically changes that don't touch
core web2py code)?
Thanks,
Dean
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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.