load videopath from backend

correctly redirect to login page if login fails
This commit is contained in:
lukas 2021-05-09 19:38:59 +02:00
parent f7705aef98
commit da07dc04bd

View File

@ -64,22 +64,26 @@ export namespace token {
console.log(APiHost);
fetch(APiHost + 'token', {method: 'POST', body: formData}).then((response) =>
response.json().then((result: APIToken) => {
if (result.error) {
callFuncQue(result.error);
return;
}
// set api token
apiToken = result.access_token;
// set expire time
expireSeconds = new Date().getTime() / 1000 + result.expires_in;
// setTokenCookie(apiToken, expireSeconds);
tokenStore.setToken({accessToken: apiToken, expireTime: expireSeconds, tokenType: '', scope: ''});
// call all handlers and release flag
callFuncQue('');
})
);
fetch(APiHost + 'token', {method: 'POST', body: formData})
.then((response) =>
response.json().then((result: APIToken) => {
if (result.error) {
callFuncQue(result.error);
return;
}
// set api token
apiToken = result.access_token;
// set expire time
expireSeconds = new Date().getTime() / 1000 + result.expires_in;
// setTokenCookie(apiToken, expireSeconds);
tokenStore.setToken({accessToken: apiToken, expireTime: expireSeconds, tokenType: '', scope: ''});
// call all handlers and release flag
callFuncQue('');
})
)
.catch((e) => {
callback(e);
});
}
export function apiTokenValid(): boolean {