From d9cf7f7443948844cf1236c1a543f77c78b4e6f1 Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 24 Aug 2022 02:24:05 -0500 Subject: [PATCH] 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. --- app/controllers/users_controller.rb | 2 +- test/functional/users_controller_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e2da988b4..3b9cd93ac 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 9a4a111e2..05d403fbe 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -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