Skip to content

Commit

Permalink
Merge pull request #4151 from mw75/master
Browse files Browse the repository at this point in the history
Use editor path in generating localStorage keys
  • Loading branch information
knolleary committed Apr 28, 2023
2 parents 53f99ec + ed2c9d2 commit 792b310
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

http://nodered.org

[![Build Status](https://travis-ci.org/node-red/node-red.svg?branch=master)](https://travis-ci.org/node-red/node-red)
[![Build Status](https://github.com/node-red/node-red/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/node-red/node-red/actions?query=branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/node-red/node-red/badge.svg?branch=master)](https://coveralls.io/r/node-red/node-red?branch=master)

Low-code programming for event-driven applications.
Expand Down
14 changes: 8 additions & 6 deletions packages/node_modules/@node-red/editor-client/src/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ RED.settings = (function () {
if (!hasLocalStorage()) {
return;
}
if (key === "auth-tokens") {
localStorage.setItem(key, JSON.stringify(value));
if (key.startsWith("auth-tokens")) {
localStorage.setItem(key+this.authTokensSuffix, JSON.stringify(value));
} else {
RED.utils.setMessageProperty(userSettings,key,value);
saveUserSettings();
Expand All @@ -52,8 +52,8 @@ RED.settings = (function () {
if (!hasLocalStorage()) {
return undefined;
}
if (key === "auth-tokens") {
return JSON.parse(localStorage.getItem(key));
if (key.startsWith("auth-tokens")) {
return JSON.parse(localStorage.getItem(key+this.authTokensSuffix));
} else {
var v;
try { v = RED.utils.getMessageProperty(userSettings,key); } catch(err) {}
Expand All @@ -71,8 +71,8 @@ RED.settings = (function () {
if (!hasLocalStorage()) {
return;
}
if (key === "auth-tokens") {
localStorage.removeItem(key);
if (key.startsWith("auth-tokens")) {
localStorage.removeItem(key+this.authTokensSuffix);
} else {
delete userSettings[key];
saveUserSettings();
Expand All @@ -99,6 +99,8 @@ RED.settings = (function () {

var init = function (options, done) {
var accessTokenMatch = /[?&]access_token=(.*?)(?:$|&)/.exec(window.location.search);
var path=window.location.pathname.slice(0,-1);
RED.settings.authTokensSuffix=path.replace(/\//g, '-');
if (accessTokenMatch) {
var accessToken = accessTokenMatch[1];
RED.settings.set("auth-tokens",{access_token: accessToken});
Expand Down

0 comments on commit 792b310

Please sign in to comment.