Module: TkhAuthenticationActionControllerExtension::InstanceMethods
- Defined in:
- lib/tkh_authentication/tkh_authentication_action_controller_extension.rb
Instance Method Summary collapse
- #administrator? ⇒ Boolean
- #authenticate ⇒ Object
- #authenticate_with_admin ⇒ Object
- #current_user ⇒ Object
Instance Method Details
#administrator? ⇒ Boolean
25 26 27 |
# File 'lib/tkh_authentication/tkh_authentication_action_controller_extension.rb', line 25 def administrator? current_user && current_user.admin? end |
#authenticate ⇒ Object
11 12 13 14 15 16 |
# File 'lib/tkh_authentication/tkh_authentication_action_controller_extension.rb', line 11 def authenticate if current_user.nil? session[:target_page] = request.url redirect_to login_url, alert: t('authentication.warning.login_needed') end end |
#authenticate_with_admin ⇒ Object
18 19 20 21 22 23 |
# File 'lib/tkh_authentication/tkh_authentication_action_controller_extension.rb', line 18 def authenticate_with_admin unless administrator? session[:target_page] = request.url if session[:target_page].nil? redirect_to safe_root_url, alert: t('authentication.warning.restricted_access') end end |
#current_user ⇒ Object
7 8 9 |
# File 'lib/tkh_authentication/tkh_authentication_action_controller_extension.rb', line 7 def current_user @current_user ||= User.find_by_auth_token!([:auth_token]) if [:auth_token] end |