about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/api/v1/accounts_controller.rb7
-rw-r--r--config/routes.rb7
-rw-r--r--spec/controllers/api/v1/accounts_controller_spec.rb7
3 files changed, 17 insertions, 4 deletions
diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb
index 50e6df80e..d43306f7b 100644
--- a/app/controllers/api/v1/accounts_controller.rb
+++ b/app/controllers/api/v1/accounts_controller.rb
@@ -1,11 +1,16 @@
 class Api::V1::AccountsController < ApiController
   before_action :doorkeeper_authorize!
-  before_action :set_account
+  before_action :set_account, except: :verify_credentials
   respond_to    :json
 
   def show
   end
 
+  def verify_credentials
+    @account = current_user.account
+    render action: :show
+  end
+
   def following
     @following = @account.following
   end
diff --git a/config/routes.rb b/config/routes.rb
index 06e927822..771294453 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -29,7 +29,7 @@ Rails.application.routes.draw do
 
   resource  :settings, only: [:show, :update]
   resources :media, only: [:show]
-  
+
   namespace :api do
     # PubSubHubbub
     resources :subscriptions, only: [:show]
@@ -59,10 +59,11 @@ Rails.application.routes.draw do
       resources :follows,  only: [:create]
       resources :media,    only: [:create]
       resources :apps,     only: [:create]
-      
+
       resources :accounts, only: [:show] do
         collection do
           get :relationships
+          get :verify_credentials
         end
 
         member do
@@ -78,7 +79,7 @@ Rails.application.routes.draw do
   end
 
   get :about, to: 'about#index'
-  
+
   root 'home#index'
 
   match '*unmatched_route', via: :all, to: 'application#raise_not_found'
diff --git a/spec/controllers/api/v1/accounts_controller_spec.rb b/spec/controllers/api/v1/accounts_controller_spec.rb
index bc7c78c70..7a67f1c56 100644
--- a/spec/controllers/api/v1/accounts_controller_spec.rb
+++ b/spec/controllers/api/v1/accounts_controller_spec.rb
@@ -18,6 +18,13 @@ RSpec.describe Api::V1::AccountsController, type: :controller do
     end
   end
 
+  describe 'GET #verify_credentials' do
+    it 'returns http success' do
+      get :verify_credentials
+      expect(response).to have_http_status(:success)
+    end
+  end
+
   describe 'GET #statuses' do
     it 'returns http success' do
       get :statuses, params: { id: user.account.id }