diff options
author | Mike Crute <mike@crute.us> | 2021-11-16 22:18:39 -0800 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2021-11-17 07:56:17 -0800 |
commit | 75c1a00a0915f49fa6b5a5d40b72b53e7dbecfd8 (patch) | |
tree | 8af509cec66c091115abd9541a173ac762c78529 /templates | |
parent | e90d734c7c70513a21a7eaf78e424b2a190f2f1c (diff) | |
download | cloud-identity-broker-75c1a00a0915f49fa6b5a5d40b72b53e7dbecfd8.tar.bz2 cloud-identity-broker-75c1a00a0915f49fa6b5a5d40b72b53e7dbecfd8.tar.xz cloud-identity-broker-75c1a00a0915f49fa6b5a5d40b72b53e7dbecfd8.zip |
Allow JS access to auth token for display
Diffstat (limited to 'templates')
-rw-r--r-- | templates/index.tpl | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/templates/index.tpl b/templates/index.tpl index cbc7a72..2a5e853 100644 --- a/templates/index.tpl +++ b/templates/index.tpl | |||
@@ -174,9 +174,13 @@ | |||
174 | return document.cookie.match(new RegExp(name + "=\"?([^;\"]*)\"?;?"))[1]; | 174 | return document.cookie.match(new RegExp(name + "=\"?([^;\"]*)\"?;?"))[1]; |
175 | } | 175 | } |
176 | 176 | ||
177 | function parseJWTExpires(token) { | ||
178 | return new Date(JSON.parse(atob(token.split(".")[1]))["exp"] * 1000); | ||
179 | } | ||
180 | |||
177 | function populateAPIKey() { | 181 | function populateAPIKey() { |
178 | document.querySelector("#api-key textarea").innerText = getCookie("session"); | 182 | document.querySelector("#api-key textarea").innerText = "Bearer " + getCookie("github-token"); |
179 | document.querySelector("#session-expires").innerText = getCookie("session-expires"); | 183 | document.querySelector("#session-expires").innerText = parseJWTExpires(getCookie("github-token")); |
180 | } | 184 | } |
181 | 185 | ||
182 | window.addEventListener('load', populateAPIKey); | 186 | window.addEventListener('load', populateAPIKey); |