From 41a17f47ae275f8e84de03115e142cc23526bacc Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Fri, 3 Mar 2023 20:34:06 -0600 Subject: AƱade refactorizaciones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ea108b4..7f803c8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,22 +6,9 @@ class ApplicationController < ActionController::API @logic = Object.const_get("#{self.class}::#{action_name.camelize}Logic").new(permitted_params) end - protected + private - def current_user_account - return if decoded_token.nil? - - email = decoded_token[0]['data'] - @current_user_account ||= UserAccount.find_by(email:) - end - - def authentication_token - @authentication_token ||= request.headers[:authorization]&.sub(/^Bearer /, '') - end - - def decoded_token - @decoded_token ||= JWT.decode(authentication_token, ENV['HMAC_SECRET_KEY'], true, { algorithm: 'HS512' }) - rescue JWT::ExpiredSignature - @decoded_token = nil + def generate_token + Services::TokenGenerationService.new(service_params).call(DateTime.current + 5.days) end end -- cgit v1.2.3