<commit_before>class AccountController < ApplicationController

  stylesheet 'account'

  before_filter :view_setup

  skip_before_filter :redirect_unverified_user, :only => [:unverified, :login, :logout, :signup, :verify_email]

  # TODO: it would be good to require post for logout in the future
  verify :method => :post, :only => [:language]

  def index
    if logged_in?
      redirect_to me_url
    end
    render :action => 'login', :layout => 'base_for_login'
  end

  def login
    if !( params[:redirect].empty? || params[:redirect] =~ /^https?:\/\/#{request.domain}/ || params[:redirect] =~ /^\//)
      flash_message(:title => I18n.t(:illegal_redirect),
      :error => I18n.t(:redirect_to_foreign_domain, :url => params.delete(:redirect)))
      redirect_to params and return
    end
    unless request.post?
      render :action => 'login', :layout => 'base_for_login'
      return 
    end
    previous_language = session[:language_code]

    self.current_user = User.authenticate(params[:login], params[:password])
    if logged_in?
      reset_session # important!!
                    # always force a new session on every login success
                    # in order to prevent session fixation attacks.
      # have to reauth, since we cleared the session
      self.current_user = User.authenticate(params[:login], params[:password])

      if params[:remember_me] == "1"
        self.current_user.remember_me
        cookies[:auth_token] = {
          :value => self.current_user.remember_token,
          :expires => self.current_user.remember_token_expires_at
        }
      end

      if self.current_user.language.any?
        session[:language_code] = self.current_user.language.to_sym
      else
        session[:language_code] = previous_language
      end

      current_site.add_user!(current_user)
      UnreadActivity.create(:user => current_user)
      redirect_successful_login
    else
      flash_message_now :title => I18n.t(:login_failed),
      :error => I18n.t(:login_failure_reason)
    end

  end

  def signup
    if current_site.signup_redirect_url.any?
      redirect_to current_site.signup_redirect_url
    elsif !may_signup?<commit_msg>fix Bug #1541<commit_after>class AccountController < ApplicationController

  stylesheet 'account'

  before_filter :view_setup

  skip_before_filter :redirect_unverified_user, :only => [:unverified, :login, :logout, :signup, :verify_email]

  # TODO: it would be good to require post for logout in the future
  verify :method => :post, :only => [:language]

  def index
    if logged_in?
      redirect_to me_url
    end
    render :action => 'login', :layout => 'base_for_login'
  end

  def login
    if !( params[:redirect].empty? || params[:redirect] =~ /^https?:\/\/#{request.domain}/ || params[:redirect] =~ /^\//)
      flash_message(:title => I18n.t(:illegal_redirect),
      :error => I18n.t(:redirect_to_foreign_domain, :url => params.delete(:redirect)))
      redirect_to params and return
    end
    unless request.post?
      render :action => 'login', :layout => 'base_for_login'
      return 
    end
    previous_language = session[:language_code]

    self.current_user = User.authenticate(params[:login], params[:password])
    if logged_in?
      reset_session # important!!
                    # always force a new session on every login success
                    # in order to prevent session fixation attacks.
      # have to reauth, since we cleared the session
      self.current_user = User.authenticate(params[:login], params[:password])

      if params[:remember_me] == "1"
        self.current_user.remember_me
        cookies[:auth_token] = {
          :value => self.current_user.remember_token,
          :expires => self.current_user.remember_token_expires_at
        }
      end

      if self.current_user.language.any?
        session[:language_code] = self.current_user.language.to_sym
      else
        session[:language_code] = previous_language
      end

      current_site.add_user!(current_user)
      UnreadActivity.create(:user => current_user)
      redirect_successful_login
    else
      flash_message_now :title => I18n.t(:login_failed),
      :error => I18n.t(:login_failure_reason)
    end
    render :action => 'login', :layout => 'base_for_login'
    
  end

  def signup
    if current_site.signup_redirect_url.any?
      redirect_to current_site.signup_redirect_url
    elsif !may_signup?
{'fraction_non_alphanumeric': 0.10868094701240136, 'fraction_numerical': 0.00496054114994363, 'mean_word_length': 3.1074074074074076, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '2632495', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1311, 'n_words': 300}