[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) {
|
async function postPath(path) {
|
||||||
const resp = await fetch(path, { method: "POST" });
|
const resp = await fetch(path, { method: "POST" });
|
||||||
if (resp.status === 401 || resp.status === 403) {
|
if (resp.status === 401) {
|
||||||
// Auth error - return to login
|
// Not authenticated - return to login
|
||||||
authRole = null;
|
authRole = null;
|
||||||
if (es) es.close();
|
if (es) es.close();
|
||||||
showAuthGate();
|
showAuthGate();
|
||||||
throw new Error("Authentication required");
|
throw new Error("Authentication required");
|
||||||
}
|
}
|
||||||
|
if (resp.status === 403) {
|
||||||
|
// Authenticated but insufficient permissions - don't redirect
|
||||||
|
throw new Error("Insufficient permissions");
|
||||||
|
}
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
const text = await resp.text();
|
const text = await resp.text();
|
||||||
throw new Error(text || resp.statusText);
|
throw new Error(text || resp.statusText);
|
||||||
|
|||||||
Reference in New Issue
Block a user