Module: MinimalistAuthentication::Controller
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/minimalist_authentication/controller.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#authorized?(_action = action_name, _resource = controller_name) ⇒ Boolean
Returns true if the user is logged in Override this method in your controller to customize authorization.
-
#current_user ⇒ Object
Returns the current user from the client application Current class.
-
#logged_in? ⇒ Boolean
Returns true if a current user is present, otherwise returns false.
-
#login_redirect_to ⇒ Object
Returns the path to redirect to after login.
-
#update_current_user(user) ⇒ Object
Logs in a user by setting the session key and updating the Current user Should only be called after a successful authentication.
Instance Method Details
#authorized?(_action = action_name, _resource = controller_name) ⇒ Boolean
Returns true if the user is logged in Override this method in your controller to customize authorization
34 35 36 |
# File 'lib/minimalist_authentication/controller.rb', line 34 def (_action = action_name, _resource = controller_name) logged_in? end |
#current_user ⇒ Object
Returns the current user from the client application Current class
39 40 41 |
# File 'lib/minimalist_authentication/controller.rb', line 39 def current_user ::Current.user end |
#logged_in? ⇒ Boolean
Returns true if a current user is present, otherwise returns false
44 45 46 |
# File 'lib/minimalist_authentication/controller.rb', line 44 def logged_in? current_user.present? end |
#login_redirect_to ⇒ Object
Returns the path to redirect to after login
49 50 51 |
# File 'lib/minimalist_authentication/controller.rb', line 49 def login_redirect_to public_send(MinimalistAuthentication.configuration.login_redirect_path) end |
#update_current_user(user) ⇒ Object
Logs in a user by setting the session key and updating the Current user Should only be called after a successful authentication
55 56 57 58 59 |
# File 'lib/minimalist_authentication/controller.rb', line 55 def update_current_user(user) reset_session session[MinimalistAuthentication.session_key] = user.id ::Current.user = user end |