[web2py] Re: Delete space from users email in auth form
Yes, it's work: def user(): if request.post_vars.email: request.post_vars.email = request.post_vars.email.strip() return dict(form=auth()) -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Delete space from users email in auth form
1. Oops, instead of request.vars it should be request.post_vars 2. As 1st validator try CLEANUP('\s') -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Delete space from users email in auth form
Today I tried both of variant: first in default.py def user(): if request.vars.email: request.vars.email = request.vars.email.lower().strip() return dict(form=auth()) don't work - "incorrect email" second, I don't sure that all right here in db.py def emailStrip(): form.vars.email = form.vars.email.strip() return form.vars.email auth.settings.table_user.email.requires=[emailStrip,IS_LOWER(),IS_EMAIL(),IS_NOT_IN_DB(db,auth.settings.table_user.email)] I have found custom validators in book also but don't know how to use it. Where I need to write class? class sample_validator: def __init__(self, *a, error_message='error'): self.a = a self.e = error_message def __call__(self, value): if validate(value): return (parsed(value), None) return (value, self.e) def formatter(self, value): return format(value) -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Delete space from users email in auth form
Thank you, I try to change it ) -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Delete space from users email in auth form
`onvalidation` is what happens *after *form validation is passed. You can add your validators to auth_user.email.requires (they should be first on the validators list ) or you can insert your formatters in user() controller, I mean: def user(): if request.vars.email: request.vars.email = request.vars.email.lower().strip() return dict(form=auth()) On Friday, November 23, 2018 at 9:11:15 AM UTC+3, Константин Комков wrote: > > I do like that: > def email_to_lower(form): > form.vars.email = form.vars.email.lower() > form.vars.email = form.vars.email.strip() > auth.settings.login_onvalidation = email_to_lower > But I have message that my email is incorrect, if I enter ' > myem...@gmail.com ' > > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Delete space from users email in auth form
I do like that: def email_to_lower(form): form.vars.email = form.vars.email.lower() form.vars.email = form.vars.email.strip() auth.settings.login_onvalidation = email_to_lower -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Delete space from users email in auth form
You can use auth.settings.login_onvalidation to strip the email string. -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.