aboutsummaryrefslogtreecommitdiff
path: root/views/authenticate.js
diff options
context:
space:
mode:
Diffstat (limited to 'views/authenticate.js')
-rw-r--r--views/authenticate.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/views/authenticate.js b/views/authenticate.js
index 8b158ce..398794a 100644
--- a/views/authenticate.js
+++ b/views/authenticate.js
@@ -1,3 +1,25 @@
+var cookieStorage = {
+ getItem: function(index) {
+ let cookies = document.cookie.split(';');
+ for (cookie of cookies) {
+ let values = cookie.trim().split('=');
+ if (values[0] === index) {
+ return values[1];
+ }
+ }
+ return undefined;
+ },
+ setItem: function(index, value, expires = 'Fri, 31 Dec 9999 23:59:59 GMT') {
+ let cookie = index + '=' + value + ';';
+ cookie += 'expires=' + expires + ';';
+ cookie += 'path=/';
+ document.cookie = cookie;
+ },
+ removeItem: function(index) {
+ cookieStorage.setItem(index, "", 'Thu, 01 Jan 1970 00:00:00 GMT');
+ },
+};
+
var authentication_response = null;
var authentication_callbacks = [];
@@ -9,7 +31,6 @@ function requestAuthentication() {
authentication_response = (request.status == 200) ? request.responseText : "";
}
request.open("POST", "/authenticate", true);
- request.setRequestHeader("Authorization", sessionStorage.getItem("token"));
request.send(null);
}
requestAuthentication();