<commit_before>module Sinatra
  module SessionHelper
    def please_login(notice = nil)
      if current_user.guest?
        flash[:notice] = notice if notice
        redirect "/please-login?return_path=#{request.path_info}"
      end
    end

    def login_url(return_path = nil)
      url = Github.login_url
      if return_path
        url << "&redirect_uri=#{site_root}/github/callback#{return_path}"
      end
      url
    end

    def login(user)
      session[:github_id] = user.github_id
      @current_user = user
    end

    def logout
      session[:github_id] = nil
      @current_user = nil
    end

    def current_user
      @current_user ||= logged_in_user || Guest.new
    end

    def logged_in_user
      if session[:github_id]
        User.where(github_id: session[:github_id]).first
      end
    end
  end
end

<commit_msg>Extract redirect params in github login<commit_after>module Sinatra
  module SessionHelper
    def please_login(notice = nil)
      if current_user.guest?
        flash[:notice] = notice if notice
        redirect "/please-login?return_path=#{request.path_info}"
      end
    end

    def login_url(return_path = nil)
      url = Github.login_url
      url << redirect_uri(return_path) if return_path
      url
    end

    def redirect_uri(return_path)
      "&redirect_uri=#{site_root}/github/callback#{return_path}"
    end

    def login(user)
      session[:github_id] = user.github_id
      @current_user = user
    end

    def logout
      session[:github_id] = nil
      @current_user = nil
    end

    def current_user
      @current_user ||= logged_in_user || Guest.new
    end

    def logged_in_user
      if session[:github_id]
        User.where(github_id: session[:github_id]).first
      end
    end
  end
end


{'fraction_non_alphanumeric': 0.0855374226223973, 'fraction_numerical': 0.0, 'mean_word_length': 2.5, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '7299492', 'n_tokens_mistral': 569, 'n_tokens_neox': 554, 'n_words': 126}