Module: Rodauth::Rails::Feature::Base
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/rodauth/rails/feature/base.rb
Instance Method Summary collapse
-
#clear_session ⇒ Object
Reset Rails session to protect from session fixation attacks.
-
#flash_error_key ⇒ Object
Default the flash error key to Rails’ default :alert.
- #rails_account ⇒ Object
- #rails_account_model ⇒ Object
- #rails_controller ⇒ Object
-
#rails_controller_eval(&block) ⇒ Object
Evaluates the block in context of a Rodauth controller instance.
- #session ⇒ Object
Instance Method Details
#clear_session ⇒ Object
Reset Rails session to protect from session fixation attacks.
21 22 23 |
# File 'lib/rodauth/rails/feature/base.rb', line 21 def clear_session rails_controller_instance.reset_session end |
#flash_error_key ⇒ Object
Default the flash error key to Rails’ default :alert.
26 27 28 |
# File 'lib/rodauth/rails/feature/base.rb', line 26 def flash_error_key :alert end |
#rails_account ⇒ Object
15 16 17 18 |
# File 'lib/rodauth/rails/feature/base.rb', line 15 def rails_account @rails_account = nil if account.nil? || @rails_account&.id != account_id @rails_account ||= instantiate_rails_account if account! end |
#rails_account_model ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/rodauth/rails/feature/base.rb', line 43 def rails_account_model table = accounts_table table = table.column if table.is_a?(Sequel::SQL::QualifiedIdentifier) # schema is specified table.to_s.classify.constantize rescue NameError raise Error, "cannot infer account model, please set `rails_account_model` in your rodauth configuration" end |
#rails_controller ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/rodauth/rails/feature/base.rb', line 35 def rails_controller if only_json? && ::Rails.configuration.api_only ActionController::API else ActionController::Base end end |
#rails_controller_eval(&block) ⇒ Object
Evaluates the block in context of a Rodauth controller instance.
31 32 33 |
# File 'lib/rodauth/rails/feature/base.rb', line 31 def rails_controller_eval(&block) rails_controller_instance.instance_exec(&block) end |
#session ⇒ Object
53 54 55 56 57 |
# File 'lib/rodauth/rails/feature/base.rb', line 53 def session super rescue Roda::RodaError fail Rodauth::Rails::Error, "There is no session middleware configured, see instructions on how to add it: https://guides.rubyonrails.org/api_app.html#using-session-middlewares" end |