Skip to content
Snippets Groups Projects
Commit a3637342 authored by Gabriel Zachmann's avatar Gabriel Zachmann Committed by Gabriel Zachmann
Browse files

improve web storage handling

parent f541f1f1
No related branches found
No related tags found
No related merge requests found
Pipeline #323243 passed
......@@ -19,10 +19,10 @@ function _checkIfLoggedIn(...next) {
let token = res['token'];
let iss = token['oidc_iss'];
if (iss) {
storageSet('oidc_issuer', iss, true);
storageSet('oidc_issuer', iss);
}
let scopes = extractMaxScopesFromToken(token);
storageSet('token_scopes', scopes, true);
storageSet('token_scopes', scopes);
if (window.location.pathname === "/") {
window.location.href = "/home";
}
......
......@@ -27,7 +27,7 @@ $('#login-form').on('submit', function (e) {
data['client_type'] = 'web';
data['redirect_uri'] = '/home';
data['name'] = "mytoken-web";
storageSet("oidc_issuer", data["oidc_issuer"], true);
storageSet("oidc_issuer", data["oidc_issuer"]);
data = JSON.stringify(data);
$.ajax({
type: "POST",
......
function logout() {
revokeMT(function () {
storageClear();
window.location.href = "/"
})
});
}
\ No newline at end of file
......@@ -18,12 +18,16 @@ function storageGet(key) {
return JSON.parse(v);
}
function storagePop(key, session = false) {
function storagePop(key) {
let v = storageGet(key);
storageSet(key, "", session);
storageSet(key, "");
return v;
}
function storageSet(key, value, session = false) {
return _storage(session).setItem(key, JSON.stringify(value));
function storageSet(key, value) {
return _storage(true).setItem(key, JSON.stringify(value));
}
function storageClear() {
_storage(true).clear();
}
......@@ -30,7 +30,7 @@ function exchangeTransferCode() {
}),
success: function (data) {
let token = data['mytoken'];
storageSet("tokeninfo_token", token, true);
storageSet("tokeninfo_token", token);
$('#info-tab').click();
},
error: function (errRes) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment