summaryrefslogtreecommitdiff
path: root/app/controllers/api
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-02-23 18:52:38 -0600
committerHombreLaser <sebastian-440@live.com>2023-02-23 18:52:38 -0600
commitea087f5bdc183b9c773979b795e366cc268aadaa (patch)
tree7ace77faec8b40799c543a8fa0de3658947f549c /app/controllers/api
parent97ba3df5e5970d29064daf56309e73df85a70613 (diff)
Añade spec del controlador de autenticaciones
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/authentications_controller/create_logic.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/app/controllers/api/authentications_controller/create_logic.rb b/app/controllers/api/authentications_controller/create_logic.rb
index 173db58..e3af94d 100644
--- a/app/controllers/api/authentications_controller/create_logic.rb
+++ b/app/controllers/api/authentications_controller/create_logic.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-module Services
+module Api
class AuthenticationsController
# The logic for the create method of AuthenticationsController.
class CreateLogic
@@ -11,23 +11,19 @@ module Services
end
def call
- return false if @user_account.nil? && wrong_user_password?
+ jwt = { token: service.call(DateTime.now + 30.minutes), refresh: service.call(DateTime.now + 3.days) }
- { token: service.call(DateTime.now + 30.minutes), refresh: service.call(DateTime.now + 3.days) }
+ return jwt if @user_account&.authenticate(@password)
end
private
- def wrong_user_password?
- @user_account.password != @password
- end
-
def service
@service ||= Services::TokenGenerationService.new(service_params)
end
def service_params
- { email: @email, role: @user_account.role}
+ { email: @email, role: @user_account.role }
end
end
end