Module: Rodauth::Rails

Defined in:
lib/rodauth/rails.rb,
lib/rodauth/rails/app.rb,
lib/rodauth/rails/railtie.rb,
lib/rodauth/rails/version.rb,
lib/rodauth/rails/app/flash.rb,
lib/rodauth/rails/middleware.rb,
lib/rodauth/rails/app/middleware.rb,
lib/rodauth/rails/controller_methods.rb,
lib/generators/rodauth/views_generator.rb,
lib/generators/rodauth/mailer_generator.rb,
lib/generators/rodauth/install_generator.rb,
lib/generators/rodauth/migration_helpers.rb,
lib/generators/rodauth/migration_generator.rb

Defined Under Namespace

Modules: ControllerMethods, Generators Classes: App, Error, Middleware, Railtie

Constant Summary collapse

Feature =

Assign feature and feature configuration to constants for introspection.

FEATURES[:rails]
FeatureConfiguration =
FEATURES[:rails].configuration
VERSION =
"0.8.2"

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.appObject



52
53
54
55
56
# File 'lib/rodauth/rails.rb', line 52

def app
  fail Rodauth::Rails::Error, "app was not configured" unless @app

  @app.constantize
end

.middleware=(value) ⇒ Object (writeonly)

Sets the attribute middleware

Parameters:

  • value

    the value to set the attribute middleware to.



50
51
52
# File 'lib/rodauth/rails.rb', line 50

def middleware=(value)
  @middleware = value
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



45
46
47
# File 'lib/rodauth/rails.rb', line 45

def configure
  yield self
end

.middleware?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/rodauth/rails.rb', line 58

def middleware?
  @middleware
end

.rodauth(name = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rodauth/rails.rb', line 16

def rodauth(name = nil)
  url_options = ActionMailer::Base.default_url_options

  scheme   = url_options[:protocol] || "http"
  port     = url_options[:port]
  port   ||= Rack::Request::DEFAULT_PORTS[scheme] if Gem::Version.new(Rack.release) < Gem::Version.new("2.0")
  host     = url_options[:host]
  host    += ":#{port}" if port

  rack_env = {
    "HTTP_HOST"       => host,
    "rack.url_scheme" => scheme,
  }

  scope = app.new(rack_env)

  scope.rodauth(name)
end

Instance Method Details

#secret_key_baseObject



36
37
38
# File 'lib/rodauth/rails.rb', line 36

def secret_key_base
  ::Rails.application.secret_key_base
end