Skip to content

Commit

Permalink
delete cache after an error with auth endpoint
Browse files Browse the repository at this point in the history
This solves #146 where you would get an error message after changing the authorization endpoint if the site had already cached your endpoint. Now it will delete the cache if it encounters that error, so starting over will find the new endpoint.
  • Loading branch information
aaronpk committed Sep 24, 2017
1 parent 3cf0747 commit 008dca1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions controllers/auth-web.rb
Expand Up @@ -287,7 +287,7 @@ def save_response_type
}
end
end

# If only one profile is set, and it's an indieauth authorization endpoint, then skip directly to it
if @profiles.length == 1 && @profiles[0]['provider'] == 'indieauth'
profile = @profiles[0]
Expand Down Expand Up @@ -466,10 +466,11 @@ def save_response_type
return erb :error
end

# TODO: if the user had only one auth endpoint and they were redirected here skipping the prompt,
# then we need to clear the cache and re-check for an endpoint for them.
# if the user had only one auth endpoint and they were redirected here skipping the prompt,
# then we need to clear the cache tell them to try again
if !links.include?(profile) and !auth_endpoints.include?(profile) and !gpg_keys.map{|a| a[:href]}.include?(profile)
@message = "\"#{params[:profile]}\" was not found on the site \"#{params[:me]}\". Try re-scanning after checking your rel=me links on your site."
Profile.delete_profile me
@message = "\"#{params[:profile]}\" was not found on the site \"#{params[:me]}\". The cache has been cleared, please go back and try again."
title "Error"
return erb :error
end
Expand Down

0 comments on commit 008dca1

Please sign in to comment.