Class: Wallaby::SecureController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wallaby/secure_controller.rb

Overview

This controller only contains authentication logics

Direct Known Subclasses

BaseController

Constant Summary

Constants inherited from ApplicationController

ApplicationController::ERROR_PATH

Instance Method Summary collapse

Methods inherited from ApplicationController

#bad_request, #configuration, configuration, #healthy, #not_found, #unprocessable_entity

Instance Method Details

#current_userObject

Precedence of current_user:

  • Security

    @see Wallaby::SecureController#security_config

  • super

  • do nothing

Returns:

  • a user object

See Also:

  • Devise::Controllers::Helpers#define_helpers


28
29
30
31
32
33
34
35
# File 'app/controllers/wallaby/secure_controller.rb', line 28

def current_user
  @current_user ||=
    if security_config.current_user? || !defined? super
      instance_exec(&security_config.current_user)
    else
      super
    end
end

#forbidden(exception = nil) ⇒ Object

Forbidden page

Parameters:

  • exception (Exception) (defaults to: nil)


18
19
20
# File 'app/controllers/wallaby/secure_controller.rb', line 18

def forbidden(exception = nil)
  error_rendering(exception, __callee__)
end

#security_configWallaby::Configuration::Security

Returns security configuration.

Returns:



38
39
40
# File 'app/controllers/wallaby/secure_controller.rb', line 38

def security_config
  configuration.security
end

#unauthorized(exception = nil) ⇒ Object

Unauthorized page

Parameters:

  • exception (Exception) (defaults to: nil)


12
13
14
# File 'app/controllers/wallaby/secure_controller.rb', line 12

def unauthorized(exception = nil)
  error_rendering(exception, __callee__)
end