Class: Rodauth::Rails::App
- Inherits:
-
Roda
- Object
- Roda
- Rodauth::Rails::App
- Defined in:
- lib/rodauth/rails/app.rb
Overview
The superclass for creating a Rodauth middleware.
Defined Under Namespace
Modules: RequestMethods
Class Method Summary collapse
- .configure(*args, render: Rodauth::Rails.tilt?, **options, &block) ⇒ Object
- .rodauth!(name) ⇒ Object
Instance Method Summary collapse
-
#flash ⇒ Object
API-only Rails apps don't have flash support, in which case we fall back to Roda's flash.
- #rails_cookies ⇒ Object
- #rails_request ⇒ Object
- #rails_routes ⇒ Object
Class Method Details
.configure(*args, render: Rodauth::Rails.tilt?, **options, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rodauth/rails/app.rb', line 13 def self.configure(*args, render: Rodauth::Rails.tilt?, **, &block) auth_class = args.shift if args[0].is_a?(Class) auth_class ||= Class.new(Rodauth::Rails::Auth) name = args.shift if args[0].is_a?(Symbol) fail ArgumentError, "need to pass optional Rodauth::Auth subclass and optional configuration name" if args.any? # we'll render Rodauth's built-in view templates within Rails layouts plugin :render, layout: false unless render == false plugin :rodauth, auth_class: auth_class, name: name, csrf: false, json: true, render: render, **, &block # we need to do it after request methods from rodauth have been included self::RodaRequest.include RequestMethods end |
Instance Method Details
#flash ⇒ Object
API-only Rails apps don't have flash support, in which case we fall back to Roda's flash.
41 42 43 44 45 46 47 |
# File 'lib/rodauth/rails/app.rb', line 41 def flash if ActionDispatch::Request.method_defined?(:flash) rails_request.flash else super end end |
#rails_cookies ⇒ Object
53 54 55 |
# File 'lib/rodauth/rails/app.rb', line 53 def rails_request. end |
#rails_request ⇒ Object
57 58 59 |
# File 'lib/rodauth/rails/app.rb', line 57 def rails_request ActionDispatch::Request.new(env) end |
#rails_routes ⇒ Object
49 50 51 |
# File 'lib/rodauth/rails/app.rb', line 49 def rails_routes ::Rails.application.routes.url_helpers end |