Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #4928 broke admin's ability to set user's favorites via API #4983

Open
disconn3ct opened this issue Jan 29, 2025 · 2 comments
Open

PR #4928 broke admin's ability to set user's favorites via API #4983

disconn3ct opened this issue Jan 29, 2025 · 2 comments
Labels
bug Something isn't working triage

Comments

@disconn3ct
Copy link

disconn3ct commented Jan 29, 2025

I have a script (below) that copies favorites from one user to another. With the changes in #4928 it does not seem possible for an admin token to set a user's favorites.

The original request was POST to /api/users/UUID-UUID/favorites/recipe_ID. That returns "Use the Admin API to update other users". Switching to /api/admin/users/UUID-UUID/favorites/recipe_ID returns "detail": "Method Not Allowed" regardless of POST or PUT.

Script:

#/bin/ash

set -euo pipefail
# Default to TOKEN
RTOKEN=${READTOKEN:-$TOKEN}
WTOKEN=${WRITETOKEN:-$TOKEN}

curl -sS -H "accept: application/json" -H"Authorization: Bearer $RTOKEN" -X GET "$MEALIEURL/api/users/$READUSER/favorites" | \
  jq -r ".ratings[].recipeId" | \
  while read a; do 
    curl -sS -H "accept: application/json" -H"Authorization: Bearer $WTOKEN" -X PUT "$MEALIEURL/api/admin/users/$WRITEUSER/favorites/$a" 
  done
@Kuchenpirat Kuchenpirat added bug Something isn't working triage labels Jan 29, 2025
@Kuchenpirat
Copy link
Collaborator

Hi, thanks for reporting this issue. Please use our issue template next time.

I don't know if we actually want an admin to be able to set a users favorites. I would argue no. Admins should be able to administer users but setting a users favs seems a bit outside of scope for this.
What is the usecase where you would need this?

@disconn3ct
Copy link
Author

(No idea why it didn't prompt the form. Let me know if there is info you need and I'll update from a PC later.)

In this case, we have a location user ("kitchen") who's favorites are synced one-way from the human users. Since it's a service user, it is not a huge deal to use self, but it's at least a regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

2 participants