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/api/user_accounts_controller | |
parent | 10ec03fbdfa0c7394c58aa64094c94aeb1887d86 (diff) |
Refactoriza las clases de logic
Diffstat (limited to 'app/controllers/api/user_accounts_controller')
-rw-r--r-- | app/controllers/api/user_accounts_controller/create_logic.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/controllers/api/user_accounts_controller/create_logic.rb b/app/controllers/api/user_accounts_controller/create_logic.rb new file mode 100644 index 0000000..3876c00 --- /dev/null +++ b/app/controllers/api/user_accounts_controller/create_logic.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Api + class UserAccountsController + # The UserAccountsController CreateLogic class. + class CreateLogic + attr_reader :user_account + + include TokenGenerationConcern + + def initialize(params) + @params = params + end + + def call + @user_account = UserAccount.new(@params) + + return unless @user_account.save + + generate_user_session_key + generate_token + end + + private + + def service_params + { email: @user_account.email, role: @user_account.role, session_key: @user_account.session_key } + end + end + end +end |