Use token expiration for cache
This commit is contained in:
parent
6ab016128c
commit
9072669576
@ -23,8 +23,9 @@ async function login(widget, service) {
|
||||
const [, , data] = await httpProxy(loginUrl, loginParams);
|
||||
|
||||
try {
|
||||
const { token } = JSON.parse(data.toString());
|
||||
cache.put(`${sessionTokenCacheKey}.${service}`, token);
|
||||
const { token, expiresAt } = JSON.parse(data.toString());
|
||||
const expiresAtDate = new Date(expiresAt).getTime();
|
||||
cache.put(`${sessionTokenCacheKey}.${service}`, token, expiresAtDate - Date.now());
|
||||
return { token };
|
||||
} catch (e) {
|
||||
logger.error("Unable to login to Homebox API: %s", e);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user