<commit_before>class SamlController < ApplicationController
  skip_before_filter :require_login, :except => [:logout]
  protect_from_forgery except: :consume

  def init
    request = OneLogin::RubySaml::Authrequest.new
    redirect_to(request.create(SAML_SETTINGS))
  end

  def consume

    response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], :settings => SAML_SETTINGS)

    if response.success?
      email = response.attributes["urn:oid:0.9.2342.19200300.100.1.3"]
      @user = User.find_by_email(email)
      unless @user.blank?
        auto_login @user
        User.increment_counter(:visit_count, @user.id)
        session[:course_id] = @user.default_course.id
        respond_with @user, location: dashboard_path
      else
        render text: "invite them to gradecraft"
      end
    else
       redirect_to root_url, :notice => "authentication error"
    end
  end

  def metadata
    meta = OneLogin::RubySaml::Metadata.new
    render :xml => meta.generate(SAML_SETTINGS, true)
  end

  def logout
    redirect_to logout_url
  end


end
<commit_msg>Redirect UM users without an account to the pilot signup page<commit_after>class SamlController < ApplicationController
  skip_before_filter :require_login, :except => [:logout]
  protect_from_forgery except: :consume

  def init
    request = OneLogin::RubySaml::Authrequest.new
    redirect_to(request.create(SAML_SETTINGS))
  end

  def consume

    response = OneLogin::RubySaml::Response.new(params[:SAMLResponse], :settings => SAML_SETTINGS)

    if response.success?
      email = response.attributes["urn:oid:0.9.2342.19200300.100.1.3"]
      @user = User.find_by_email(email)
      unless @user.blank?
        auto_login @user
        User.increment_counter(:visit_count, @user.id)
        session[:course_id] = @user.default_course.id
        respond_with @user, location: dashboard_path
      else
        redirect_to um_pilot_path
      end
    else
       redirect_to root_url, :notice => "authentication error"
    end
  end

  def metadata
    meta = OneLogin::RubySaml::Metadata.new
    render :xml => meta.generate(SAML_SETTINGS, true)
  end

  def logout
    redirect_to logout_url
  end


end

{'fraction_non_alphanumeric': 0.09356458238247375, 'fraction_numerical': 0.01734367868553172, 'mean_word_length': 3.4643584521384927, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 2, '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': '1863929', 'n_tokens_mistral': 745, 'n_tokens_neox': 693, 'n_words': 148}