Skip to content

Commit

Permalink
(fixes #2410, BP from #1668) added the validation in opAuthRegisterFo…
Browse files Browse the repository at this point in the history
…rmMailAddress for application and e-mail
  • Loading branch information
martini2002jp authored and watanabe committed Mar 7, 2012
1 parent 74e2191 commit 3d34623
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/form/opAuthRegisterFormMailAddress.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function configure()

// Hack for non-rendering secret answer
$this->configForm->getWidget('secret_answer')->setOption('type', 'text');

$this->mergePostValidator(new sfValidatorCallback(array('callback' => array($this, 'validateMemberConfig'))));
}

public function bindAll($request)
Expand Down Expand Up @@ -61,4 +63,27 @@ public function doSave()
$memberConfig->save();
return $memberConfig;
}

public function validateMemberConfig($validator, $values, $arguments = array())
{
if (sfConfig::get('app_is_mobile', false))
{
$memberConfig = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId('mobile_address_pre', $this->getMember()->getId());
if (!$memberConfig)
{
throw new sfValidatorError($validator, 'Can access this registration URL with pc only.');
}
}
else
{
$memberConfig = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId('pc_address_pre', $this->getMember()->getId());
if (!$memberConfig)
{
throw new sfValidatorError($validator, 'Can access this registration URL with mobile only.');
}
}

return $values;
}

}

0 comments on commit 3d34623

Please sign in to comment.