summaryrefslogtreecommitdiff
path: root/app/controllers/api/user_accounts_controller/create_logic.rb
blob: 2e686b3a0eab5b82ffadb51de87c5e80ea23ec14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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(@user_account)
        generate_token
      end
    end
  end
end