web/admin: fix error when me() returns 403
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
9d3b6f7a4d
commit
71e4936dc3
|
@ -5,10 +5,16 @@ let _globalMePromise: Promise<SessionUser>;
|
|||
export function me(): Promise<SessionUser> {
|
||||
if (!_globalMePromise) {
|
||||
_globalMePromise = new CoreApi(DEFAULT_CONFIG).coreUsersMe().catch((ex) => {
|
||||
const defaultUser: SessionUser = {
|
||||
user: {
|
||||
username: "",
|
||||
name: ""
|
||||
}
|
||||
};
|
||||
if (ex.status === 401 || ex.status === 403) {
|
||||
window.location.assign("/");
|
||||
}
|
||||
return ex;
|
||||
return defaultUser;
|
||||
});
|
||||
}
|
||||
return _globalMePromise;
|
||||
|
|
Reference in New Issue