summaryrefslogtreecommitdiff
path: root/app/controllers/api/authentications_controller
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-02-25 00:20:23 -0600
committerHombreLaser <sebastian-440@live.com>2023-02-25 00:20:23 -0600
commita64b2dfeb543ef38f4c7cd38eb05baec9e84a2d9 (patch)
tree4448177d2a8f2a567d7dd5b75074a30f805528c1 /app/controllers/api/authentications_controller
parent10ec03fbdfa0c7394c58aa64094c94aeb1887d86 (diff)
Refactoriza las clases de logic
Diffstat (limited to 'app/controllers/api/authentications_controller')
-rw-r--r--app/controllers/api/authentications_controller/create_logic.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/app/controllers/api/authentications_controller/create_logic.rb b/app/controllers/api/authentications_controller/create_logic.rb
index c62c300..2f42852 100644
--- a/app/controllers/api/authentications_controller/create_logic.rb
+++ b/app/controllers/api/authentications_controller/create_logic.rb
@@ -4,6 +4,8 @@ module Api
class AuthenticationsController
# The logic for the create method of AuthenticationsController.
class CreateLogic
+ include TokenGenerationConcern
+
def initialize(params)
@email = params[:email]
@password = params[:password]
@@ -13,17 +15,12 @@ module Api
def call
return unless @user_account&.authenticate(@password)
- @user_account.session_key = SecureRandom.hex(16)
- @user_account.save
- { token: service.call(DateTime.current + 30.minutes), refresh: service.call(DateTime.current + 3.days) }
+ generate_user_session_key
+ generate_token
end
private
- def service
- @service ||= Services::TokenGenerationService.new(service_params)
- end
-
def service_params
{ email: @email, role: @user_account.role, session_key: @user_account.session_key }
end