From the book http://web2py.com/books/default/chapter/29/09#Authenticationwe
know that:
*The password field of the db.auth_user table defaults to a CRYPT validator*
From http://web2py.com/books/default/chapter/29/09#Customizing-Auth we know
also that:
*You can add any field you wish, and you can change validators but you
cannot remove the fields marked as required*
(namely 'email', 'password', 'registration_key', 'reset_password_key',
'registration_id' fields)
Finally we know that (
http://web2py.com/books/default/chapter/29/07#Validators):
*error_message* allows you to override the default error message for any
validator.
Consequently we can change the validators of auth.password field and
customize error messages.
We could accomplish our target in the following way for example:
# in model db.py after auth.define_tables(username=False, signature=False)
default_password_validators = [def_val for def_val
in db.auth_user.password.requires]
added_password_validators = [IS_NOT_EMPTY(error_message=T('Enter a value')),
IS_LENGTH(minsize=8,
error_message=T('Invalid password'))]
password_validators = added_password_validators +default_password_validators
db.auth_user.password.requires = password_validators
Il giorno mercoledì 21 novembre 2012 14:38:31 UTC+1, Daniele ha scritto:
Hiding the error is not my point. I want an error message when the user
inputs an invalid email/password combination. However, the error message
should just say something like Email or password invalid. It shouldn't be
running the same check as it does when a user registers a password...
On Wednesday, November 21, 2012 12:22:46 AM UTC, Daniele wrote:
For some reason, I am not getting the right error messages to display on
my login form.
Right now, I'm getting the same errors that one should get upon
registration, such as:
Minimum length is 8
Must include at least 1 upper case
Must include at least 1 number
However, this is giving away too many clues for a mere login. I just want
the message to say password or email incorrect or something along those
lines. How can I do this?
--