summaryrefslogtreecommitdiff
path: root/app/controllers/api/user_accounts_controller.rb
blob: 3e03cf9f5ce95742f187e052ae6695e8fe55c2f0 (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
26
# frozen_string_literal: true

module Api
  # The UserAccounts controller.
  class UserAccountsController < AuthenticatedController
    skip_before_action :validate_jwt, only: [:create]

    def show
      render json: serialized_user_account.serializable_hash
    end

    def create
      @token = logic(permitted_params).call

      render json: @token, status: :ok and return if @token

      render json: { errors: @logic.user_account.errors.full_messages }, status: :unprocessable_entity
    end

    private

    def permitted_params
      params.require(:user_account).permit(:role, :email, :first_name, :last_name, :password)
    end
  end
end