Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert changes to ensure_login (Hoping this just adds to the PR, and …
…not to your forked repo)
  • Loading branch information
Deer-Spangle authored Mar 2, 2023
commit abaa8ca54a254907f9b8811247dda322550b6038
16 changes: 4 additions & 12 deletions lib/faexport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ def initialize(app, config = {})
FAExport.config[:cache_time_long] ||= 86_400 # 1 day
FAExport.config[:redis_url] ||= (ENV["REDIS_URL"] || ENV["REDISTOGO_URL"])
FAExport.config[:cookie] ||= ENV["FA_COOKIE"]
FAExport.config[:key] ||= ENV["key"]
FAExport.config[:rss_limit] ||= 10
FAExport.config[:content_types] ||= {
"json" => "application/json",
Expand All @@ -260,20 +259,13 @@ def set_content_type(type)
content_type FAExport.config[:content_types][type], "charset" => "utf-8"
end

def ensure_login!
if @user_cookie
raise FALoginCookieError.new(
'You must provide a valid login cookie in the header "FA_COOKIE".'\
"Please note this is a header, not a cookie. #{@user_cookie}"
)
end
def ensure_login!
return if @user_cookie

if !(params[:key] == FAExport.config[:key])
raise FALoginCookieError.new(
"Unauthorised key provided."
'You must provide a valid login cookie in the header "FA_COOKIE".'\
"Please note this is a header, not a cookie."
)
end
return true
end

def record_metrics(endpoint, format, &block)
Expand Down