Skip to content

Commit

Permalink
Added TTL to local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
strobosco committed Nov 2, 2021
1 parent 480acd9 commit 9f7aae4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions frontend/pages/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const getReturnedParamsFromSpotifyAuth = (hash) => {
const stringAfterHashtag = hash.substring(1);
const paramsInUrl = stringAfterHashtag.split("&");
const paramsSplitUp = paramsInUrl.reduce((acc, currentValue) => {
console.log(currentValue);
const [key, value] = currentValue.split("=");
acc[key] = value;
return acc;
Expand All @@ -23,10 +22,13 @@ const redirect = () => {

localStorage.clear();

localStorage.setItem("accessToken", access_token);
localStorage.setItem("tokenType", token_type);
localStorage.setItem("expiresIn", expires_in);
console.log(localStorage);
const data = {
value: access_token,
ttl: Date.now() + expires_in * 1000,
};

// store data in LocalStorage
localStorage.setItem("accessToken", JSON.stringify(data));

window.location = "/";
}
Expand Down

0 comments on commit 9f7aae4

Please sign in to comment.