HI!
2 suggestions:
1) in your validator configure method add something like:
public function configure($options = array(), $messages = array())
{
$this->addOption('username_field', 'username');
$this->addMessage('unknown', 'There is no user found with this e-mail
address');
}
2) Don't use this error message: "There is no user found with this e-mail
address", My opinion is to default the message beck to invalid. this way, i
won't be able do things like:
"Hmmmm... let's se if [email protected] is an user of this
system".. "Oh it is (by those two different error messages)... now let's
find out the pass / bruteforce"
if you still want to ignore the #2, you might make a custom filter...
Every 5 mistakes, you could say to 'hacker' "hold on a little bit... don't
stress the system: this is the pass" :P (of course is a bad joke)
Alecs
On Thu, Oct 8, 2009 at 2:39 PM, HAUSa <
[email protected]> wrote:
>
> Is is possible to throw an own error message in a custom validator?
>
> Check this:
> if(!$oUser) throw new sfValidatorError($oValidator, 'unknown');
> elseif(sha1($oUser->getSalt() . $aArguments['password']) != $oUser-
> >getPassword()) throw new sfValidatorError($oValidator, 'invalid');
> else return $oUser;
>
> This is my form:
> new sfValidatorCallback(
> array(
> 'callback' => array('kmValidatorSignIn', 'execute'),
> 'arguments' => array('password' => sfContext::getInstance()-
> >getRequest()->getParameter('sign_in[password]'))
> ),
> array(
> 'invalid' => 'The e-mail address or the password is
> invalid',
> 'unknown' => 'There is no user found with this e-mail
> address'
> )
> )
>
> But, helas, I receive this error message when I open the page:
> "sfValidatorCallback does not support the following error codes:
> 'unknown'."
>
> Someone who knows how I can make this own validator error code?
> >
>
--
As programmers create bigger & better idiot proof programs, so the universe
creates bigger & better idiots!
I am on web: http://www.alecslupu.ro/
I am on twitter: http://twitter.com/alecslupu
I am on linkedIn: http://www.linkedin.com/in/alecslupu
Tel: (+4)0748.543.798
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---