In my client side application(vuejs) user can have multiple accounts with different access tokens and refresh tokens, so i save them as an array in local storage and cookie but when i store refresh tokens in one array in cookie i can't put different expiration time for each of them. how should i make this work? or any different idea to store multiple refresh tokens?
refresh tokens array:
refreshTokensList = [{ accountId: 'xxxx', refreshToken: 'yyyy' }, { accountId: 'qqqq', refreshToken: 'rrrr' }]
I set them like below:
const setRefreshToken = (token, accountId) => {
let refreshTokensList = JSON.parse(
JSON.stringify(getCookie(refreshTokens)),
);
const item = refreshTokensList.find((rt) => rt.accountId === accountId);
if (!item) {
refreshTokensList.push({ accountId, token });
}
setCookie(refreshTokens, refreshTokensList, 2);
};