[fix](trx-frontend-http): don't redirect to login on 403 (insufficient permissions)
Only redirect to login on 401 (unauthenticated). For 403 errors (authenticated but insufficient role), let the caller handle the error. This prevents rx-authenticated users from being redirected to login when they attempt to scroll the jog wheel or frequency input, which tries to call /set_freq (a control-only endpoint). RX users will now see "Insufficient permissions" hint instead of being sent to login screen. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
@@ -961,13 +961,17 @@ function disconnect() {
|
||||
|
||||
async function postPath(path) {
|
||||
const resp = await fetch(path, { method: "POST" });
|
||||
if (resp.status === 401 || resp.status === 403) {
|
||||
// Auth error - return to login
|
||||
if (resp.status === 401) {
|
||||
// Not authenticated - return to login
|
||||
authRole = null;
|
||||
if (es) es.close();
|
||||
showAuthGate();
|
||||
throw new Error("Authentication required");
|
||||
}
|
||||
if (resp.status === 403) {
|
||||
// Authenticated but insufficient permissions - don't redirect
|
||||
throw new Error("Insufficient permissions");
|
||||
}
|
||||
if (!resp.ok) {
|
||||
const text = await resp.text();
|
||||
throw new Error(text || resp.statusText);
|
||||
|
||||
Reference in New Issue
Block a user