Glad it helped, Dsvid. BTW, step 1, is not required AFAIK, as email
addresses appear to be stored in lower case by default. The place to
check less documented features of w2p is epydoc at
http://localhost:8000/examples/static/epydoc/index.html
IS_LOWER() is a validator not a formatter, so all it could do is ask
the user to enter his email address in lower case (it would not
automatically convert the email address to lowercase before storing it
in the db). Check out epydoc, if you like, to figure out whether email
addresses are converted to lower case by default.

=HC

On Sep 19, 4:41 pm, "david.waldrop" <david.wald...@gmail.com> wrote:
> HC thanks that worked like a charm.  I must confess I think this
> should be a bit more straightforward and I woiuld not have figured out
> the separate places I needed to manipulate a users email address to
> make this work.    For others who may encounter this need here is a
> consolidated summary of ensuring email matches across the built in
> registration and login features of web2py:
>
> 1) add in a constraint to the email filed of auth.users by using a
> requires (requires=IS_LOWER(),IS_EMAIL() ) .  This ensures the email
> is stored in lower case during registration and profile update.
>
> 2) defining a validation function that converts an email address to
> lower case. (and knowing that it needed to receive a form as a
> parameter,and it was possible to change the values of the submitted
> form)
>
>           # setup conversion of email address to lower case upon
> clogin
>           def email_to_lower(form):
>               form.vars.email = form.vars.email.lower()
>
> 3) hooking the function defined in step 2 to be called after login and
> changing the case of the email the user entered to lowercase (this
> ensures it will match and make a better experience for the user).
> This is done as follows:
>
>           auth.settings.login_onvalidation = email_to_lower
>
> On Sep 18, 5:28 am, hcvst <hcv...@googlemail.com> wrote:
>
>
>
> > Hi David,
>
> > somehow, doesn't look pretty but this works.
>
> > def email_to_lower(form):
> >     form.vars.email = form.vars.email.lower()
>
> > auth.settings.login_onvalidation = email_to_lower
>
> > I guess the login form should not be case sensitive. (Or should it,
> > Massimo?)
>
> > Regards,
> > HC

Reply via email to