Class: SignIn::LogoutRedirectGenerator

Inherits:
Object
  • Object
show all
Defined in:
app/services/sign_in/logout_redirect_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_config:, credential_type: nil) ⇒ LogoutRedirectGenerator

Returns a new instance of LogoutRedirectGenerator.



9
10
11
12
# File 'app/services/sign_in/logout_redirect_generator.rb', line 9

def initialize(client_config:, credential_type: nil)
  @credential_type = credential_type
  @client_config = client_config
end

Instance Attribute Details

#client_configObject (readonly)

Returns the value of attribute client_config.



7
8
9
# File 'app/services/sign_in/logout_redirect_generator.rb', line 7

def client_config
  @client_config
end

#credential_typeObject (readonly)

Returns the value of attribute credential_type.



7
8
9
# File 'app/services/sign_in/logout_redirect_generator.rb', line 7

def credential_type
  @credential_type
end

Instance Method Details

#authenticated_with_logingov?Boolean (private)

Returns:

  • (Boolean)


30
31
32
# File 'app/services/sign_in/logout_redirect_generator.rb', line 30

def authenticated_with_logingov?
  credential_type == Constants::Auth::LOGINGOV
end

#logingov_serviceObject (private)



38
39
40
# File 'app/services/sign_in/logout_redirect_generator.rb', line 38

def logingov_service
  AuthenticationServiceRetriever.new(type: Constants::Auth::LOGINGOV).perform
end

#logout_redirect_uriObject (private)



34
35
36
# File 'app/services/sign_in/logout_redirect_generator.rb', line 34

def logout_redirect_uri
  @logout_redirect_uri ||= client_config&.logout_redirect_uri
end

#parse_logout_redirect_uriObject (private)



26
27
28
# File 'app/services/sign_in/logout_redirect_generator.rb', line 26

def parse_logout_redirect_uri
  URI.parse(logout_redirect_uri).to_s
end

#performObject



14
15
16
17
18
19
20
21
22
# File 'app/services/sign_in/logout_redirect_generator.rb', line 14

def perform
  return unless logout_redirect_uri

  if authenticated_with_logingov?
    logingov_service.render_logout(logout_redirect_uri)
  else
    parse_logout_redirect_uri
  end
end