Commit 3e17b2c
authored
Remove generator default overriding navigational_formats (#515)
`config/initializers/devise.rb` sets `navigational_formats` twice. An
earlier line sets it to `[]` (alongside `skip_session_storage =
[:http_auth, :token_auth]`), which is the intended API-only behaviour.
The generator's stock block further down then overrides it with `["*/*",
:html]`.
With `*/*` treated as navigational, Devise's failure app takes the
redirect branch on auth failure. On GET requests it calls
`store_location!`, which writes to the session - disabled on this app -
raising `DisabledSessionError`. So a GET auth failure without a JSON
`Accept` header returns 500 instead of 401. POST failures return 302 (no
session write, since `store_location!` only stores on GET).
Not reachable from the SPA, which sends `Accept: application/json` and
gets 401 as expected. Surfaced via curl.
**Change:** delete the duplicate assignment and its boilerplate comment,
leaving `[]` as the effective value. No sign-in page exists on this
API-only backend to redirect to.
**Verified on UAT:** locked account with a valid token, `GET /users`, no
`Accept` header - 500 (`DisabledSessionError`) before, 401 after. JSON
`Accept` path unchanged.
**Note:** the 401 now carries `content-type: */*; charset=utf-8`
(echoing `request.format`). Cosmetic - body is still JSON.
Independent of #508/#512; branched off `sg-dev`.1 parent c5902a4 commit 3e17b2c
1 file changed
Lines changed: 0 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | 234 | | |
246 | 235 | | |
247 | 236 | | |
| |||
0 commit comments