I'm a newby using Symfony 1.2 but I think you are implementing a
validator based on symfony 1.0 if you are sure that this is correct
try by editing the file:
plugins/sfDoctrineGuardPlugin/lib/form/doctrine/base/BasesfGuardFormSignin.class.php

change the following line:
this->validatorSchema->setPostValidator(new sfGuardValidatorUser());

by:
$this->validatorSchema->setPostValidator(new sfGuardUserByEmailValidator ());


Regards,

Gary Rojas

2009/5/5 justin_davis <jdavis1...@gmail.com>:
>
> Hey all,
>
> I'm using Symfony 1.2 and Doctrine, with the sfDoctrineGuard plugin.
> I have a table for profile information called sfDoctrineGuardProfile.
> Creating a new user and profile works great.
>
> I want the user to be able to log in with their email address, instead
> of a username.  I set the username field in the sfDoctrineGuard schema
> to allow null values.  I found an email signin validation script here
> (http://bluehorn.co.nz/2009/04/29/implementing-email-login-with-
> sfguardplugin/) and modified it to work with doctrine.  The email
> validation is as follows:
>
> class sfGuardUserByEmailValidator extends sfValidator
> {
> public function initialize($context, $parameters = null)
> {
> // initialize parent
> parent::initialize($context);
>
> // set defaults
> $this->getParameterHolder()->set(’username_error’, ‘Email or password
> is not valid.’);
> $this->getParameterHolder()->set(’password_field’, ‘password’);
> $this->getParameterHolder()->set(’remember_field’, ‘remember’);
>
> $this->getParameterHolder()->add($parameters);
>
> return true;
> }
>
> public function execute(&$value, &$error)
> {
> $password_field = $this->getParameterHolder()->get(’password_field’);
> $password = $this->getContext()->getRequest()->getParameter
> ($password_field);
>
> $remember = false;
> $remember_field = $this->getParameterHolder()->get(’remember_field’);
> $remember = $this->getContext()->getRequest()->getParameter
> ($remember_field);
>
> $email = $value;
>
> $profile = sfGuardUserProfileTable::retrieveByEmail($email);
> if (!$profile) return false;
>
> $user = $profile->getsfGuardUser();
>
> // user exists and active?
> if ($user and $user->getIsActive())
> {
> // password is ok?
> if ($user->checkPassword($password))
> {
> $this->getContext()->getUser()->signIn($user, $remember);
>
> return true;
> }
> }
>
> $error = $this->getParameterHolder()->get(’username_error’);
>
> return false;
> }
> }
>
> How do I make sfGuardAuth use this validator instead of the default
> one?  I tried, per the blog post, creating a signin.yml file with the
> following values:
>
> methods:
>  post: [username, password]
>
> names:
>  username:
>  required:         true
>  required_msg:     Your username is required
>  validators:       [userValidator]
>
> password:
>  required:         true
>  required_msg:     Your password is required
>
> userValidator:
>  class:            sfGuardUserByEmailValidator
>  param:
>    password_field: password
>    remember_field: remember
>
> Placed that in apps/frontend/modules/sfGuardAuth/validate/signin.yml
> and it doesn't seem to be working.  I'm still getting username/
> password errors, instead of email/password errors.
>
> Basically, how do I override the standard sfGuardAuth validator and
> substitute this one?
>
> Thanks so much!
>
> Justin
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to