Class: Boar::Handlers::Authentication

Inherits:
Generic
  • Object
show all
Defined in:
app/models/boar/handlers/authentication.rb

Instance Attribute Summary

Attributes inherited from Generic

#configuration, #service

Instance Method Summary collapse

Methods inherited from Generic

#initialize

Methods included from Utils::Basic

#ensure_hash, #get_option, #interpolate

Constructor Details

This class inherits a constructor from Boar::Handlers::Generic

Instance Method Details

#authenticate_for(_ = nil) ⇒ Object



32
33
34
35
# File 'app/models/boar/handlers/authentication.rb', line 32

def authenticate_for(_ = nil)
  # By default we are authenticating
  true
end

#authenticating_for?(_ = nil) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/boar/handlers/authentication.rb', line 23

def authenticating_for?(_ = nil)
  false # By default we're not authentication
end

#call(*args) ⇒ Object



10
11
12
13
14
15
16
17
# File 'app/models/boar/handlers/authentication.rb', line 10

def call(*args)
  # Get path
  path = args[0]

  if self.required_for?(path) then
    self.authenticating_for?(path) ? self.authenticate_for(path) : self.request_authentication_for(path)
  end
end

#request_authentication_for(_ = nil) ⇒ Object



27
28
29
30
# File 'app/models/boar/handlers/authentication.rb', line 27

def request_authentication_for(_ = nil)
  # Render the view for authentication
  @service.controller.render(@service.handler_for(:views).call(:authentication))
end

#required_for?(_ = nil) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/models/boar/handlers/authentication.rb', line 19

def required_for?(_ = nil)
  false # By default we don't require authentication
end