Re: [web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
the issue is I see with the debugger in the case of register - the validator executes after register telling 'Invalid Email' when I copy/paste an email with space after the email itself. I want to prevent this to happen.
Re: [web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
You might use the CLEANUP validator -- it strips whitespace before removing special characters. If you don't want to remove any characters and just want to strip the whitespace, you can specify your own empty regex: CLEANUP(regex='') Anthony On Friday, December 16, 2011 9:18:47 PM UTC-5, thstart wrote: > > How to perform a function to strip out white spaces before > registration? >
Re: [web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
How to perform a function to strip out white spaces before registration?
Re: [web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
I tend to agree. On Friday, December 16, 2011 2:39:06 PM UTC-5, thstart wrote: > > I believe this is a bug - it should be consistent - > when I state: db.auth_user.email.requires.in**sert(0, IS_LOWER()) > > On Fri, Dec 16, 2011 at 11:33 AM, Anthony wrote: > >> When using email as the login username, looks like auth.login() >> temporarily replaces the email field validator(s) with just an IS_EMAIL >> validator (maybe that should be changed). So, for login, you probably need >> to use an onvalidation function to convert to lowercase. >> >> Anthony >> >> >> On Friday, December 16, 2011 12:14:37 PM UTC-5, thstart wrote: >>> >>> OK I added this code after database definition: >>> >>> db.auth_user.email.requires.in**sert(0, IS_LOWER()) >>> >>> So it is always present with register and login. >>> >>> Now register is working as expected - e.g. if I >>> create first an account with lower case email >>> and then try to create an account with same >>> email but mixed case, the system does not creates >>> a new account. So this important part is working >>> now. >>> >>> But now when I try to login I always have to enter >>> lower case, with mixed case the message is >>> 'Invalid login'. here is the code: >>> >>> #auth.settings.login_**onvalidation = *login_email_lower >>> *#current.app.auth = authform=current.app.auth.login(**next=login_next) >>> >>> >>> As you see I commented out login_email_lower and >>> >>> I suppose I should return it back. >>> >>> >>> def *login_email_lower*(form): form.vars.email = >>> form.vars.email.lower() return(form) >>> >>> >>> >>> >>> >
Re: [web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
I believe this is a bug - it should be consistent - when I state: db.auth_user.email.requires.in**sert(0, IS_LOWER()) On Fri, Dec 16, 2011 at 11:33 AM, Anthony wrote: > When using email as the login username, looks like auth.login() > temporarily replaces the email field validator(s) with just an IS_EMAIL > validator (maybe that should be changed). So, for login, you probably need > to use an onvalidation function to convert to lowercase. > > Anthony > > > On Friday, December 16, 2011 12:14:37 PM UTC-5, thstart wrote: >> >> OK I added this code after database definition: >> >> db.auth_user.email.requires.in**sert(0, IS_LOWER()) >> >> So it is always present with register and login. >> >> Now register is working as expected - e.g. if I >> create first an account with lower case email >> and then try to create an account with same >> email but mixed case, the system does not creates >> a new account. So this important part is working >> now. >> >> But now when I try to login I always have to enter >> lower case, with mixed case the message is >> 'Invalid login'. here is the code: >> >> #auth.settings.login_**onvalidation = *login_email_lower >> *#current.app.auth = authform=current.app.auth.login(**next=login_next) >> >> >> As you see I commented out login_email_lower and >> >> I suppose I should return it back. >> >> >> def *login_email_lower*(form): form.vars.email = form.vars.email.lower() >> return(form) >> >> >> >> >>
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
When using email as the login username, looks like auth.login() temporarily replaces the email field validator(s) with just an IS_EMAIL validator (maybe that should be changed). So, for login, you probably need to use an onvalidation function to convert to lowercase. Anthony On Friday, December 16, 2011 12:14:37 PM UTC-5, thstart wrote: > > OK I added this code after database definition: > > db.auth_user.email.requires.insert(0, IS_LOWER()) > > So it is always present with register and login. > > Now register is working as expected - e.g. if I > create first an account with lower case email > and then try to create an account with same > email but mixed case, the system does not creates > a new account. So this important part is working > now. > > But now when I try to login I always have to enter > lower case, with mixed case the message is > 'Invalid login'. here is the code: > > #auth.settings.login_onvalidation = *login_email_lower*#current.app.auth > = authform=current.app.auth.login(next=login_next) > > > As you see I commented out login_email_lower and > > I suppose I should return it back. > > > def *login_email_lower*(form): form.vars.email = form.vars.email.lower() >return(form) > > > > >
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
OK I added this code after database definition: db.auth_user.email.requires.insert(0, IS_LOWER()) So it is always present with register and login. Now register is working as expected - e.g. if I create first an account with lower case email and then try to create an account with same email but mixed case, the system does not creates a new account. So this important part is working now. But now when I try to login I always have to enter lower case, with mixed case the message is 'Invalid login'. here is the code: #auth.settings.login_onvalidation = *login_email_lower*#current.app.auth = authform=current.app.auth.login(next=login_next) As you see I commented out login_email_lower and I suppose I should return it back. def *login_email_lower*(form): form.vars.email = form.vars.email.lower() return(form)
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
Does the profile form not work for that? You can limit the fields available on the profile page via auth.settings.profile_fields. Anthony On Thursday, December 15, 2011 9:51:56 PM UTC-5, thstart wrote: > > I am using email/password as a login. > After login I want to have an option > for the user to be able to change his email > used as a login. > > say the user logs in with myem...@gmail.com/ > after log in he clicks on a button (change your email), > a form is present where he enters his new email > as newem...@gmail.com. > > He logs out, and now he can login with > newem...@gmail.com/ > > e.g. auth_user.email used to beĀ ...@gmail.com, > after the change to be ...@gmail.com > >
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
I am using email/password as a login. After login I want to have an option for the user to be able to change his email used as a login. say the user logs in with myem...@gmail.com/ after log in he clicks on a button (change your email), a form is present where he enters his new email as newem...@gmail.com. He logs out, and now he can login with newem...@gmail.com/ e.g. auth_user.email used to be myem...@gmail.com, after the change to be newem...@gmail.com
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
On Thursday, December 15, 2011 9:34:43 PM UTC-5, thstart wrote: > > Also, when logged in - how to make possible for the user to change > his email? > /user/profile See http://web2py.com/book/default/chapter/08#Authentication. The auth.profile method creates a "profile" form for users to edit their profile.
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
On Thursday, December 15, 2011 9:24:03 PM UTC-5, thstart wrote: > > great, I set this globally where the auth_user table is defined. > On register got the message > *'value already in database or empty'* > > how to change it? > How to change what?
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
Also, when logged in - how to make possible for the user to change his email?
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
great, I set this globally where the auth_user table is defined. On register got the message *'value already in database or empty'* how to change it?
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
Thank you, I will test it.
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
def user(): if request.args(0) == 'register': db.auth_user.email.requires.insert(0, IS_LOWER()) [rest of code] Note, the above assumes there is already at least one validator defined for the email field (which there should be by default) -- otherwise, just do requires=... Anthony On Thursday, December 15, 2011 5:09:37 PM UTC-5, thstart wrote: > > could you please post a code how to that for register especially?
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
could you please post a code how to that for register especially?
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
But did you try using the IS_LOWER validator? On Thursday, December 15, 2011 2:09:33 PM UTC-5, thstart wrote: > > I used your suggestion for 'reset_email_lower' from this thread > but it doesn't works with register. It works for login/reset_password > but not with register. > > https://groups.google.com/forum/#!topic/web2py/1QjBUy62jP8 > I added this code (reset_email_lower) to registration > too. But I checked the database and see the following: > > 1) I create a new user account with email all lower case. > 2) the app logs in as default. > 3) Log out. > 4) I try to create a new user account with same email but > first letter a capital. I see in the database that a new account is created > and the email is stored a lower cap but now I have two id's with the same > email in auth_user table > 5) after creating the new account the app logs automatically > and in auth_event I see User # Registered and in user_id column > the user_id of the other account which already was created with lower caps. > > Bottom line - when registering - how to convert the email to lower cap so > web2py to be able to check if the same email is already registered, > and if so to prevent creating of a new account and notify the user that > the account > already exist. >
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
I used your suggestion for 'reset_email_lower' from this thread but it doesn't works with register. It works for login/reset_password but not with register. https://groups.google.com/forum/#!topic/web2py/1QjBUy62jP8 I added this code (reset_email_lower) to registration too. But I checked the database and see the following: 1) I create a new user account with email all lower case. 2) the app logs in as default. 3) Log out. 4) I try to create a new user account with same email but first letter a capital. I see in the database that a new account is created and the email is stored a lower cap but now I have two id's with the same email in auth_user table 5) after creating the new account the app logs automatically and in auth_event I see User # Registered and in user_id column the user_id of the other account which already was created with lower caps. Bottom line - when registering - how to convert the email to lower cap so web2py to be able to check if the same email is already registered, and if so to prevent creating of a new account and notify the user that the account already exist.
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
Have you tried adding the IS_LOWER validator to the email field when the register form is submitted? On Thursday, December 15, 2011 1:43:27 PM UTC-5, Constantine Vasil wrote: > > How to make this possible: > > I have only email/password as login. > > Want email to be changed to lower case at the register > page and stored as a lower case to the database. > > Made this for login/reset password, how to make it > for register page as well? > > Registering with mixed case creates a new user account > with new user_id. > > >