<commit_before># This controller handles the login/logout function of the site.
class SessionsController < ApplicationController

  skip_before_filter :require_activation, :only => [:new, :destroy]

  def new
    @body = "login single-col"
  end

  def create
    if using_open_id?
      open_id_authentication(params[:openid_url])
    else
      password_authentication(params[:email],params[:password])
    end
  end

  def open_id_authentication(openid_url)
    authenticate_with_open_id(openid_url, :required => [:nickname, :email]) do |result, identity_url, registration|
      if result.successful?
        @person = Person.find_or_initialize_by_identity_url(identity_url)
        if @person.new_record?
          @person.name = registration['nickname']
          @person.email = registration['email']
          @person.save
          if !@person.errors.empty?
            @body = "login single-col"
            err_message = "Your OpenID profile must provide"
            err_message += " nickname," if !@person.errors[:name].nil?
            err_message += " email," if !@person.errors[:email].nil?

            failed_login err_message.chop
            return
          end
        end
        self.current_person = @person
        successful_login
      else
        failed_login result.message
      end
    end
  end

  def failed_login(message = "Authentication failed.")
    flash.now[:error] = message
    render :action => 'new'<commit_msg>bugfix: email_verified needs to be set when email_verifications is true<commit_after># This controller handles the login/logout function of the site.
class SessionsController < ApplicationController

  skip_before_filter :require_activation, :only => [:new, :destroy]

  def new
    @body = "login single-col"
  end

  def create
    if using_open_id?
      open_id_authentication(params[:openid_url])
    else
      password_authentication(params[:email],params[:password])
    end
  end

  def open_id_authentication(openid_url)
    authenticate_with_open_id(openid_url, :required => [:nickname, :email]) do |result, identity_url, registration|
      if result.successful?
        @person = Person.find_or_initialize_by_identity_url(identity_url)
        if @person.new_record?
          @person.name = registration['nickname']
          @person.email = registration['email']
          # XXX for now, don't mess with email verification for openid guys
          @person.email_verified = true if global_prefs.email_verifications?
          @person.save
          if !@person.errors.empty?
            @body = "login single-col"
            err_message = "Your OpenID profile must provide"
            err_message += " nickname," if !@person.errors[:name].nil?
            err_message += " email," if !@person.errors[:email].nil?

            failed_login err_message.chop
            return
          end
        end
        self.current_person = @person
        successful_login
      else
        failed_login result.message
      end
    end
  end

  def failed_login(message = "Authentication failed.")
    flash.now[:error] = message
    render :action => 'new'
{'fraction_non_alphanumeric': 0.0925392251040666, 'fraction_numerical': 0.0, 'mean_word_length': 2.795868772782503, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4137061', 'n_tokens_mistral': 890, 'n_tokens_neox': 872, 'n_words': 215}