Class: Users::DestroySessionService
- Inherits:
-
Object
- Object
- Users::DestroySessionService
- Defined in:
- app/services/users/destroy_session_service.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#private_session_id ⇒ Object
readonly
Returns the value of attribute private_session_id.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user:, user:, private_session_id:) ⇒ DestroySessionService
constructor
A new instance of DestroySessionService.
Constructor Details
#initialize(current_user:, user:, private_session_id:) ⇒ DestroySessionService
Returns a new instance of DestroySessionService.
7 8 9 10 11 |
# File 'app/services/users/destroy_session_service.rb', line 7 def initialize(current_user:, user:, private_session_id:) @current_user = current_user @user = user @private_session_id = private_session_id end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
5 6 7 |
# File 'app/services/users/destroy_session_service.rb', line 5 def current_user @current_user end |
#private_session_id ⇒ Object (readonly)
Returns the value of attribute private_session_id.
5 6 7 |
# File 'app/services/users/destroy_session_service.rb', line 5 def private_session_id @private_session_id end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'app/services/users/destroy_session_service.rb', line 5 def user @user end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/services/users/destroy_session_service.rb', line 13 def execute unless current_user.can_admin_all_resources? return ServiceResponse.error( message: 'The current user is not authorized to destroy the session', reason: :forbidden ) end ActiveSession.destroy_session(user, private_session_id) ServiceResponse.success end |