summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-02-24 23:26:00 -0600
committerHombreLaser <sebastian-440@live.com>2023-02-24 23:26:00 -0600
commit10ec03fbdfa0c7394c58aa64094c94aeb1887d86 (patch)
treed83453f54c34c883939f8ebc4a5c3858a50e64b2
parent47ea55216514f532c8e30618f621aeb93bd19eb0 (diff)
Añade método show del controlador de usuarios
-rw-r--r--app/controllers/api/user_accounts_controller.rb14
-rw-r--r--config/routes.rb3
2 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/api/user_accounts_controller.rb b/app/controllers/api/user_accounts_controller.rb
index 0825d33..b95105f 100644
--- a/app/controllers/api/user_accounts_controller.rb
+++ b/app/controllers/api/user_accounts_controller.rb
@@ -2,7 +2,13 @@
module Api
# The UserAccounts controller.
- class UserAccountsController < ApplicationController
+ class UserAccountsController < AuthenticatedController
+ skip_before_action :validate_jwt, only: [:create]
+
+ def show
+ render json: serialized_user_account.serializable_hash
+ end
+
def create
@user_account = UserAccount.new(permitted_params)
@@ -14,12 +20,14 @@ module Api
render json: Serializers::UserAccountSerializer.new(@user_account).serializable_hash
end
- # TODO: Must set authentication before defining the show method.
-
private
def permitted_params
params.require(:user_account).permit(:email, :first_name, :last_name, :password)
end
+
+ def serialized_user_account
+ @serialized_user_account ||= Serializers::UserAccountSerializer.new(current_user_account)
+ end
end
end
diff --git a/config/routes.rb b/config/routes.rb
index 45fa051..114d58b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -9,6 +9,7 @@ Rails.application.routes.draw do
post '/refresh_token', to: 'authentications#refresh'
post '/authenticate', to: 'authentications#create'
delete '/logout', to: 'authentications#destroy'
- resources :user_accounts, only: %i[show create]
+ get '/user_account', to: 'user_accounts#show'
+ resources :user_accounts, only: %i[create]
end
end