FIX: Return 404 if API access is invalid.

This commit is contained in:
Guo Xiang Tan 2017-08-10 18:27:01 +09:00
parent b84e87dedd
commit f7d3702454
2 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,8 @@ class StaffConstraint
def matches?(request)
provider = Discourse.current_user_provider.new(request.env)
provider.current_user && provider.current_user.staff?
rescue Discourse::InvalidAccess
false
end
end

View File

@ -0,0 +1,9 @@
require 'rails_helper'
RSpec.describe "Admin::AdminController" do
it "should return the right response if user isn't a staff" do
expect do
get "/admin", api_key: 'asdiasiduga'
end.to raise_error(ActionController::RoutingError)
end
end