mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-25 20:10:27 +00:00
refactor: rewrite to cookie based auth (#578)
* rewrite to cookie based auth * remove interceptor
This commit is contained in:
parent
2cd3c15215
commit
1365bdfd46
8 changed files with 155 additions and 71 deletions
|
@ -30,12 +30,15 @@ export function usePublicApi(): PublicApi {
|
|||
export function useUserApi(): UserClient {
|
||||
const authCtx = useAuthContext();
|
||||
|
||||
const requests = new Requests("", () => authCtx.token || "", {});
|
||||
const requests = new Requests("", "", {});
|
||||
requests.addResponseInterceptor(logger);
|
||||
requests.addResponseInterceptor(r => {
|
||||
if (r.status === 401) {
|
||||
console.error("unauthorized request, invalidating session");
|
||||
authCtx.invalidateSession();
|
||||
if (window.location.pathname !== "/") {
|
||||
window.location.href = "/";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue