From b72c99dbceb694f50935623f16c36dd0bf5d2c3f Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sun, 21 Jul 2024 15:16:55 +0300 Subject: [PATCH] add user api --- app/controllers/api/users_controller.rb | 11 +++++++++++ config/routes.rb | 1 + 2 files changed, 12 insertions(+) create mode 100644 app/controllers/api/users_controller.rb diff --git a/app/controllers/api/users_controller.rb b/app/controllers/api/users_controller.rb new file mode 100644 index 00000000..3505d73a --- /dev/null +++ b/app/controllers/api/users_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Api + class UsersController < ApiBaseController + authorize_resource :current_user + + def show + render json: current_user.as_json(only: %i[id first_name last_name email]) + end + end +end diff --git a/config/routes.rb b/config/routes.rb index 85fa2b5d..a3e90fc8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,6 +28,7 @@ Rails.application.routes.draw do end namespace :api, defaults: { format: :json } do + resource :user, only: %i[show] resources :attachments, only: %i[create] resources :submitter_email_clicks, only: %i[create] resources :submitter_form_views, only: %i[create]