I tried using this code to let a user login with either username or email. 
Previously it was only allowing email. It's still trying to validate the 
entry as an email address though, and if I enter a username it gives me an 
error "Invalid Email". How can I eliminate or circumvent that email 
validation?

On Saturday, June 1, 2013 7:27:05 PM UTC-7, Gustavo Souza wrote:
>
> Worked for me the following code:
>
>     if 'login' in request.args:
>         auth.settings.login_userfield = 'username'
>         if request.vars.username and not 
> IS_EMAIL()(request.vars.username)[1]:
>             auth.settings.login_userfield = 'email'
>             request.vars.email = request.vars.username
>             request.post_vars.email = request.vars.email
>             request.vars.username = None
>             request.post_vars.username = None
>
>         return dict(form=auth.login())
>
> Em sexta-feira, 9 de dezembro de 2011 10h22min57s UTC-2, Francisco Costa 
> escreveu:
>>
>> lots of users on login form submit their email instead of the
>> username..
>>
>> it seems that auth.define_tables(username=True) forces username login
>> but it is possible to have both?
>>
>

-- 
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.

Reply via email to