blob: 600e168bb026eda41d1edb9e7f7f2d39c3ebc5d3 (
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
27
28
29
30
31
|
# frozen_string_literal: true
module Api
# The UserAccounts controller.
class UserAccountsController < AuthenticatedController
skip_before_action :validate_jwt, only: [:create]
def show
render json: Serializers::UserAccountSerializer.new(current_user_account).serializable_hash
end
def create
@user_account = UserAccount.new(permitted_params.merge(role: 'regular'))
render json: generate_token, status: :ok and return if @user_account.save
render json: @user_account.errors.full_messages, status: :unprocessable_entity
end
private
def service_params
{ email: @user_account.email,
role: @user_account.role }
end
def permitted_params
params.permit(:email, :first_name, :last_name, :password)
end
end
end
|