Module: Dokno::UserConcern
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationController
- Defined in:
- app/controllers/dokno/user_concern.rb
Instance Method Summary collapse
- #authorize ⇒ Object
- #can_edit? ⇒ Boolean
- #sanitized_user_obj_string ⇒ Object
- #user ⇒ Object
- #username ⇒ Object
Instance Method Details
#authorize ⇒ Object
36 37 38 |
# File 'app/controllers/dokno/user_concern.rb', line 36 def return redirect_to root_path unless can_edit? end |
#can_edit? ⇒ Boolean
28 29 30 31 32 33 34 |
# File 'app/controllers/dokno/user_concern.rb', line 28 def can_edit? # Allow editing by default if host app user object is not configured return true unless sanitized_user_obj_string.present? return false unless user&.respond_to? Dokno.config.app_user_auth_method.to_sym user.send(Dokno.config.app_user_auth_method.to_sym) end |
#sanitized_user_obj_string ⇒ Object
20 21 22 |
# File 'app/controllers/dokno/user_concern.rb', line 20 def sanitized_user_obj_string Dokno.config.app_user_object.to_s.split(/\b/).first end |
#user ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/dokno/user_concern.rb', line 9 def user # Attempt to eval the currently signed in 'user' object from the host app proc { $safe = 1 eval sanitized_user_obj_string }.call rescue NameError => _e nil end |