users: allow anonymous users to use /profile.json.

Allow logged out users to call https://danbooru.donmai.us/profile.json.
This allows getting information on default settings and limits for
anonymous users.

May be a breaking API change if users were using the HTTP response code
from /profile.json to check if they were successfully logged in.
This commit is contained in:
evazion
2022-08-24 02:24:05 -05:00
parent e3af738371
commit d9cf7f7443
2 changed files with 3 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ class UsersController < ApplicationController
elsif request.format.html?
redirect_to login_path(url: profile_path)
else
raise ActiveRecord::RecordNotFound
respond_with(@user, methods: @user.full_attributes, template: "users/show")
end
end

View File

@@ -228,9 +228,9 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to login_path(url: "/profile")
end
should "return 404 for anonymous api calls" do
should "return success for anonymous api calls" do
get profile_path(format: :json)
assert_response 404
assert_response :success
end
end