You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Signed-out pages don't say a change needs sign-in (ticks undo silently) #675
With sign-in on (since 0e8dacf, #534), a page left open after its visitor is signed out — they signed out in another tab, their sign-in expired, or an admin removed them — still shows the controls of a signed-in user. Using one of them is refused, but the page does not say why or how to fix it:
Shopping list ticks (toggleItem in templates/shopping_list.html): the 401 is caught, the tick is taken back and the list re-read. Nothing is shown; the box just unticks itself.
Remove / Clear on the shopping list, Add to shopping list on a recipe, the pantry and aisle pages: they show the JSON error, which is the middleware's English Sign in to make changes (src/server/auth/middleware.rs), whatever the page's language, with no link to the sign-in page.
Editor save / delete: a Save failed: Sign in to make changes toast, the same English text and no link.
The same happens with 403 when a user's role is lowered while their page is open (Your role does not allow this change, also English only; the HTML 403 page is translated through role-forbidden).
The plan in #334 (§6.3) expected this case: "the JS that calls write endpoints must handle 401 with a toast 'Sign in to modify' linking to /login".
Proposal
One shared helper the pages' write calls go through: on 401, a translated message with a Sign in link to /login?next=<this page> (the nav link in base.html already builds that URL); on 403, the translated role-forbidden text.
The shopping list tick shows that message instead of silently undoing the tick.
The API's 401 / 403 bodies translated by Accept-Language like the pages, so API clients reading error get the same text.
Steps to reproduce
cook server user add alice, cook server ./seed
Sign in as alice, open the shopping list with a recipe on it in two tabs
Sign out in one tab
In the other, tick an item: it unticks itself with no message. Click Clear: "Sign in to make changes", with no link
Activity
fix(server): say why a change was refused after signing out (#683)