Commit ca8b3a2f authored by Gabriel Mazetto's avatar Gabriel Mazetto

Display error when we cannot find an OAuth Application for the Geo node

parent 9b817e66
class Oauth::GeoAuthController < ActionController::Base
rescue_from Gitlab::Geo::RemoteNode::InvalidCredentialsError, with: :invalid_credentials
rescue_from Gitlab::Geo::OauthApplicationUndefinedError, with: :undefined_oauth_application
rescue_from OAuth2::Error, with: :auth
def auth
......@@ -39,4 +40,8 @@ class Oauth::GeoAuthController < ActionController::Base
render :error, layout: 'errors'
end
def undefined_oauth_application
@error = 'There is no OAuth application defined for this Geo node.'
render :error, layout: 'errors'
end
end
module Gitlab
module Geo
class OauthApplicationUndefinedError < StandardError; end
def self.current_node
RequestStore.store[:geo_node_current] ||= begin
GeoNode.find_by(host: Gitlab.config.gitlab.host,
......@@ -43,7 +45,8 @@ module Gitlab
def self.oauth_authentication
return false unless Gitlab::Geo.secondary?
RequestStore.store[:geo_oauth_application] ||= Gitlab::Geo.current_node.oauth_application
RequestStore.store[:geo_oauth_application] ||= Gitlab::Geo.current_node.oauth_application or
raise GeoOauthApplicationUndefinedError
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment