public function postValidateForm($validator, $values)
 {
     if (isset($values['promo_code'])) {
         $promo_code = PromoCodeTable::getInstance()->findOneByCode($values['promo_code']);
         if (!$promo_code) {
             throw new sfValidatorError($validator, 'Promotion Code is invalid');
         } else {
             $values['account_type'] = $promo_code->account_type;
         }
     }
     /** @var sfGuardUser $user */
     $user = sfGuardUserTable::getInstance()->createQuery('u')->where('u.email_address = ?', $values['email_address'])->fetchOne();
     if ($user && $values['password']) {
         if ($user->getIsActive() && $user->checkPassword($values['password'])) {
             sfContext::getInstance()->getUser()->signIn($user);
             sfContext::getInstance()->getController()->redirect('/project');
         } else {
             throw new sfValidatorError($validator, 'The email and/or password is invalid');
         }
     }
     $email = $values['email_address'];
     $domain = strtolower(substr($email, strpos($email, '@') + 1));
     if (DomainTable::getInstance()->findOneBy('name', $domain)) {
         $error = new sfValidatorError($validator, 'That looks like a personal email address. Please use your company email.');
         throw new sfValidatorErrorSchema($validator, array('email_address' => $error));
     }
     return $values;
 }
 public function verifyEmailDomain($validator, $values)
 {
     $email = $values['email_address'];
     $domain = strtolower(substr($email, strpos($email, '@') + 1));
     if (DomainTable::getInstance()->findOneBy('name', $domain)) {
         $error = new sfValidatorError($validator, 'That looks like a personal email address. Please use your company email.');
         throw new sfValidatorErrorSchema($validator, array('email_address' => $error));
     }
     return $values;
 }