Skip to content

Commit

Permalink
grab user token for private assets
Browse files Browse the repository at this point in the history
this is based on the assumption the user data is available in localStorage, similar to icosa-web.
  • Loading branch information
mikeskydev committed Jun 13, 2021
1 parent 118bdba commit f0dc8bb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,12 @@ export class Loader {
}

http.open("GET", url, true);

const loggedInUser = JSON.parse(localStorage.getItem("user") as string);
if(loggedInUser) {
http.setRequestHeader("Authorization", loggedInUser.token_type as string + " " + loggedInUser.token as string);
}

http.send();
}

Expand Down Expand Up @@ -1242,6 +1248,12 @@ export class Loader {
}

http.open("GET", url, true);

const loggedInUser = JSON.parse(localStorage.getItem("user") as string);
if(loggedInUser) {
http.setRequestHeader("Authorization", loggedInUser.token_type as string + " " + loggedInUser.token as string);
}

http.send();
}

Expand Down

0 comments on commit f0dc8bb

Please sign in to comment.