mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-06 04:54:53 +02:00
Redirect UI if unauthorized API response
This commit is contained in:
parent
1b39ba70cb
commit
3aac1b2715
11 changed files with 148 additions and 77 deletions
web/src/components
|
@ -16,7 +16,7 @@ import DialogTitle from "@mui/material/DialogTitle";
|
|||
import DialogContent from "@mui/material/DialogContent";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import DialogActions from "@mui/material/DialogActions";
|
||||
import api from "../app/Api";
|
||||
import api, {UnauthorizedError} from "../app/Api";
|
||||
import routes from "./routes";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import {useNavigate, useOutletContext} from "react-router-dom";
|
||||
|
@ -152,6 +152,10 @@ const ChangePassword = () => {
|
|||
console.debug(`[Account] Password changed`);
|
||||
} catch (e) {
|
||||
console.log(`[Account] Error changing password`, e);
|
||||
if ((e instanceof UnauthorizedError)) {
|
||||
session.reset();
|
||||
window.location.href = routes.login;
|
||||
}
|
||||
// TODO show error
|
||||
}
|
||||
};
|
||||
|
@ -238,6 +242,10 @@ const DeleteAccount = () => {
|
|||
window.location.href = routes.app;
|
||||
} catch (e) {
|
||||
console.log(`[Account] Error deleting account`, e);
|
||||
if ((e instanceof UnauthorizedError)) {
|
||||
session.reset();
|
||||
window.location.href = routes.login;
|
||||
}
|
||||
// TODO show error
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue