Reputation: 1095
I'm new to web2py i'm trying to register a user without email address (a reddit style login), but i'm unable skip the email field in auth_user, i did try these because they seemed intuitive
auth.settings.registration_requires_email = False
auth.define_tables(username=True, signature=False,email=False)
However they don't exist, Any help is appreciated, Thanks.
Upvotes: 0
Views: 160
Reputation: 25536
From the Google Group:
def user():
if request.args(0) == 'register':
for field in ['first_name', 'last_name', 'email']:
db.auth_user[field].readable = db.auth_user[field].writable = False
return dict(form=auth())
The above alters the user()
function in the default.py controller so it simply hides the name and email fields in the registration form (but leaves them visible in the profile form so they can be filled in later if desired).
Upvotes: 1
Reputation: 814
Here is a link I found for Customizing Auth which explains how to do exactly what you'd like, which is use a username for authentication instead of e-mail address.
If you add a field called "username", it will be used in place of "email" for login. If you do, you will need to add a validator as well:
auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)
So it looks you'll have to leverage the define_tables()
function discussed in the link. Hope this helps!
Upvotes: 0