Not tested, but maybe something like: def user(): custom_auth.settings.login_userfield = 'username' if request.args(0) == 'login': if request.vars.username and not IS_EMAIL()(request.vars.username)[1]: custom_auth.settings.login_userfield = 'email' request.vars.email = request.vars.username return dict(form=custom_auth.login()) return dict(form=custom_auth())
On Friday, December 9, 2011 10:52:56 AM UTC-5, Francisco Costa wrote: > > I would prefer that way.. I what controller function? I'm using in > form from default/user but I'm using a customauth > > On Dec 9, 3:02 pm, Anthony <abas...@gmail.com> wrote: > > Rather than write a whole new method, one trick might be in the login > > controller function, check the incoming request.vars.username to see if > it > > is an email address (using the IS_EMAIL validator). Then, depending on > > that, dynamically set auth.settings.login_userfield to either 'email' or > > 'username', and then call auth.login() as usual. > > > > Anthony > > > > > > > > > > > > > > > > On Friday, December 9, 2011 9:50:02 AM UTC-5, Francisco Costa wrote: > > > > > yes, i think I'm going to build a custom method for login with > > > username or email > > > > > On Dec 9, 2:13 pm, Anthony <aba...@gmail.com> wrote: > > > > Are you saying you want users to be able to login with either their > > > > username or their email address? For that, I think you might need a > > > custom > > > > login method. On the other hand, if you simply want to allow users to > > > have > > > > a username, but always login with email address, you should be able > to > > > do: > > > > > > auth.settings.login_userfield = 'email' > > > > > > Anthony > > > > > > On Friday, December 9, 2011 7:22:57 AM UTC-5, Francisco Costa wrote: > > > > > > > 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? >