Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6344071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:34:00+00:00 2026-05-24T20:34:00+00:00

In User.class.php i have: $this->setCode(sha1($this->getPassword())); This is ok. In register form i would like

  • 0

In User.class.php i have:

$this->setCode(sha1($this->getPassword()));

This is ok. In register form i would like use sfValidatorDoctrineUnique.

$this->validatorSchema->setPostValidator(new sfValidatorDoctrineUnique(array('model'=>'User', 'column'=>'code')));

But this doesnt work. This check password from form without sha1 and from database with sha1. I use sfValidatorDoctrineUnique also for email (without sha1) and this working ok.
How can i fix it? I use Symfony 1.4.12

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:34:02+00:00Added an answer on May 24, 2026 at 8:34 pm

    Why the hell would you check if the password is unique? this makes totally no sense

    UPD: For creating an own validator create a /lib/valdator/sfValidatorDoctrineFoobar.class.php

    <?php
    
    class sfValidatorDoctrineFoobar extends sfValidatorBase
    {
      protected function configure($options = array(), $messages = array())
      {
        $this->addMessage('invalid_record', 'Unable to find the related record');
      }
    
      protected function doClean($value){
        $status = $this->getCodeStatus($value);
        if ($status == 1){
         throw new sfValidatorError($this, 'Code is invalid', array('value' => 'invalid code'));
        }
    
        if ($status == 2){
         throw new sfValidatorError($this, 'Code allready used', array('value' => 'used'));
        }
    
        return $value;
      }
    
      protected function getCodeStatus($value){
        $q = Doctrine_Query::create()->from('Code c');
        $q->select('c.hash, c.used');
        $q->addWhere('c.hash = ?', $value);
    
        $result = $q->fetchOne(array(), Doctrine::HYDRATE_ARRAY);
    
        if (!$result) return 1;
        if ($result['used'] == 1) return 2;
        return false;
      }
    }
    

    just to show you an example.. you’ll have to change the code to your needs 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that talks to 'process_register.php' to register a user. That file
My model is like this class Foo(models.Model): user = models.ForeignKey(User) class Meta: abstract =
I have a PHP application where I would like to certain objects to persist
I have this code in script.php: <?php session_start(); $user_session = $_SESSION['u_name']; class check_sess {
I have added this function in my user class. Is this function Place in
Ok, I have a User entity as follows <?php class User { /** *
I have the following structure otsg > class > authentication.php > database.php > user.php
I have a doctrine class User which is of this hierarchy Doctrine_Record -> BaseUser
i have this testing class <?php class IndexControllerTest extends ControllerTestCase { .... public function
I have this fsField is the class of all elements in the form. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.