Skip to content

Signed-out pages don't say a change needs sign-in (ticks undo silently) #675

Closed

Description

@LeMyst

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

  1. cook server user add alice, cook server ./seed
  2. Sign in as alice, open the shopping list with a recipe on it in two tabs
  3. Sign out in one tab
  4. In the other, tick an item: it unticks itself with no message. Click Clear: "Sign in to make changes", with no link

Activity

  1. added
    bug
    area: server
    on Oct 10, 2026
  2. added a commit that references this issue on Oct 11, 2026
    c18ae1a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: serverbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions