<commit_before><?php

/**
 * account actions.
 *
 * @package    darwin
 * @subpackage account
 * @author     DB team <<EMAIL>>
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class accountActions extends DarwinActions
{
  /**
   * Send an e-mail for password renew
   */
  protected function sendPwdRenewMail($userParams, $partial='pwdRenewMail')
  {
    $message = $this->getMailer()->compose();
    $message->setFrom(array(sfConfig::get('dw_mailer_sender') => 'DaRWIN 2 team'));
    if(is_array($userParams) && ! empty($partial))
    {
      if (isset($userParams['mail']) && isset($userParams['name']) && isset($userParams['physical']) && isset($userParams['user_id']) && isset($userParams['hash']))
      {
        if(!empty($userParams['mail']))
        {
          $message->setTo($userParams['mail']);
          $message->setSubject($this->getI18N()->__('DaRWIN 2 password renew'));
          $message->setBody($this->getPartial($partial, array('userParams'=>$userParams)),'text/plain');
          $this->getMailer()->send($message);
        }
      }
    }
  }

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeLogin(sfWebRequest $request)
  {
    $this->redirectIf($this->getUser()->isAuthenticated(),'@homepage');
    $this->form = new LoginForm();
    if ($request->hasParameter('l_err') && $request->getParameter('l_err','0') == '1')
    {
      $error = new sfValidatorError(new savedValidator(),'Bad login or password');
      $this->form->getErrorSchema()->addError($error);
    }
    if ($request->isMethod('post'))
    {
      $this->form->bind($request->getParameter('login'));
      if ($this->form->isValid())
      {
        $this->getUser()->setAuthenticated(true);
        sfContext::getInstance()->getLogger()->debug('LOGIN: '.$this->form->getValue('username').' '.$this->form->user->getId() );
        $this->getUser()->setAttribute('db_user_id',$this->form->user->getId());
        $this->getUser()->setAttribute('db_user_type',$this->form->user->getDbUserType());

        if(in_array($this->form->user->getSelectedLang(),array('en','fr','nl'))) //Prevent errors
        {
          $this->getUser()->setCulture($this->form->user->getSelectedLang());
        }

        $this->getUser()->setHelpIcon(Doctrine::getTable("Preferences")->getPreference($this->form->user->getId(),'help_message_activated',true));
        if($request->getReferer())
          $this->redirect( $request->getReferer() );
        else
          $this->redirect('@homepage');
      }
    }<commit_msg>Add notice on wrong username<commit_after><?php

/**
 * account actions.
 *
 * @package    darwin
 * @subpackage account
 * @author     DB team <<EMAIL>>
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class accountActions extends DarwinActions
{
  /**
   * Send an e-mail for password renew
   */
  protected function sendPwdRenewMail($userParams, $partial='pwdRenewMail')
  {
    $message = $this->getMailer()->compose();
    $message->setFrom(array(sfConfig::get('dw_mailer_sender') => 'DaRWIN 2 team'));
    if(is_array($userParams) && ! empty($partial))
    {
      if (isset($userParams['mail']) && isset($userParams['name']) && isset($userParams['physical']) && isset($userParams['user_id']) && isset($userParams['hash']))
      {
        if(!empty($userParams['mail']))
        {
          $message->setTo($userParams['mail']);
          $message->setSubject($this->getI18N()->__('DaRWIN 2 password renew'));
          $message->setBody($this->getPartial($partial, array('userParams'=>$userParams)),'text/plain');
          $this->getMailer()->send($message);
        }
      }
    }
  }

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeLogin(sfWebRequest $request)
  {
    $this->redirectIf($this->getUser()->isAuthenticated(),'@homepage');
    $this->form = new LoginForm();
    if ($request->hasParameter('l_err') && $request->getParameter('l_err','0') == '1')
    {
      $error = new sfValidatorError(new savedValidator(),'Bad login or password');
      $this->form->getErrorSchema()->addError($error);
    }
    if ($request->isMethod('post'))
    {
      $this->form->bind($request->getParameter('login'));
      if ($this->form->isValid())
      {
        $this->getUser()->setAuthenticated(true);
        sfContext::getInstance()->getLogger()->debug('LOGIN: '.$this->form->getValue('username').' '.$this->form->user->getId() );
        $this->getUser()->setAttribute('db_user_id',$this->form->user->getId());
        $this->getUser()->setAttribute('db_user_type',$this->form->user->getDbUserType());

        if(in_array($this->form->user->getSelectedLang(),array('en','fr','nl'))) //Prevent errors
        {
          $this->getUser()->setCulture($this->form->user->getSelectedLang());
        }

        $this->getUser()->setHelpIcon(Doctrine::getTable("Preferences")->getPreference($this->form->user->getId(),'help_message_activated',true));
        if($request->getReferer())
          $this->redirect( $request->getReferer() );
        else
          $this->redirect('@homepage');
      } else {
        sfContext::getInstance()->getLogger()->notice('Bad username or password');
      }
    }
{'fraction_non_alphanumeric': 0.20835686053077357, 'fraction_numerical': 0.009410878976096368, 'mean_word_length': 3.604852686308492, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 139, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4888188', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1629, 'n_words': 221}