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