diff options
author | HombreLaser <sebastian-440@live.com> | 2023-02-25 00:20:23 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-02-25 00:20:23 -0600 |
commit | a64b2dfeb543ef38f4c7cd38eb05baec9e84a2d9 (patch) | |
tree | 4448177d2a8f2a567d7dd5b75074a30f805528c1 /app/controllers/concerns | |
parent | 10ec03fbdfa0c7394c58aa64094c94aeb1887d86 (diff) |
Refactoriza las clases de logic
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r-- | app/controllers/concerns/token_generation_concern.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/controllers/concerns/token_generation_concern.rb b/app/controllers/concerns/token_generation_concern.rb new file mode 100644 index 0000000..7f43e4c --- /dev/null +++ b/app/controllers/concerns/token_generation_concern.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# Common logic for all the logics that require the token generation +# service. +module TokenGenerationConcern + extend ActiveSupport::Concern + + def service + @service ||= Services::TokenGenerationService.new(service_params) + end + + def generate_user_session_key + @user_account.session_key = SecureRandom.hex(16) + @user_account.save + end + + def generate_token + { token: service.call(DateTime.current + 30.minutes), refresh: service.call(DateTime.current + 3.days) } + end +end |