1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Handle and display for invalid flow credentials when project is disabled #1689 (#1694)

* Handle and display for invalid flow credentials when project is disabled #1689

* fixed extra character

* fixed whitespace
This commit is contained in:
Ted 2018-04-15 03:51:26 -07:00 committed by Nick O'Leary
parent ae9cf13fc2
commit 29e0b194dd
3 changed files with 40 additions and 11 deletions

View File

@ -179,13 +179,25 @@
]
}
} else if (msg.error === "credentials_load_failed") {
if (RED.user.hasPermission("projects.write")) {
if (RED.settings.theme("projects.enabled",false)) {
// projects enabled
if (RED.user.hasPermission("projects.write")) {
options.buttons = [
{
text: "Setup credentials",
click: function() {
persistentNotifications[notificationId].hideNotification();
RED.projects.showCredentialsPrompt();
}
}
]
}
} else {
options.buttons = [
{
text: "Setup credentials",
text: "Close",
click: function() {
persistentNotifications[notificationId].hideNotification();
RED.projects.showCredentialsPrompt();
}
}
]

View File

@ -91,6 +91,7 @@
"missing-types": "<p>Flows stopped due to missing node types.</p>",
"restartRequired": "Node-RED must be restarted to enable upgraded modules",
"credentials_load_failed": "<p>Flows stopped as the credentials could not be decrypted.</p><p>The flow credential file is encrypted, but the project's encryption key is missing or invalid.</p>",
"credentials_load_failed_reset":"<p>Credentials could not be decrypted</p><p>The flow credential file is encrypted, but the project's encryption key is missing or invalid.</p><p>The flow credential file will be reset on the next deployment. Any existing flow credentials will be cleared.</p>",
"missing_flow_file": "<p>Project flow file not found.</p><p>The project is not configured with a flow file.</p>",
"project_empty": "<p>The project is empty.</p><p>Do you want to create a default set of project files?<br/>Otherwise, you will have to manually add files to the project outside of the editor.</p>",
"project_not_found": "<p>Project '__project__' not found.</p>",

View File

@ -37,6 +37,7 @@ var activeFlowConfig = null;
var activeFlows = {};
var started = false;
var credentialsPendingReset = false;
var activeNodesToFlow = {};
var subflowInstanceNodeMap = {};
@ -70,21 +71,31 @@ function init(runtime) {
}
function loadFlows() {
return storage.getFlows().then(function(config) {
var config;
return storage.getFlows().then(function(_config) {
config = _config;
log.debug("loaded flow revision: "+config.rev);
return credentials.load(config.credentials).then(function() {
events.emit("runtime-event",{id:"runtime-state",retain:true});
return config;
});
}).catch(function(err) {
activeConfig = null;
events.emit("runtime-event",{id:"runtime-state",payload:{type:"warning",error:err.code,project:err.project,text:"notification.warnings."+err.code},retain:true});
if (err.code === "project_not_found") {
log.warn(log._("storage.localfilesystem.projects.project-not-found",{project:err.project}));
} else {
if (err.code === "credentials_load_failed" && !storage.projects) {
// project disabled, credential load failed
credentialsPendingReset = true;
log.warn(log._("nodes.flows.error",{message:err.toString()}));
events.emit("runtime-event",{id:"runtime-state",payload:{type:"warning",error:err.code,text:"notification.warnings.credentials_load_failed_reset"},retain:true});
return config;
} else {
activeConfig = null;
events.emit("runtime-event",{id:"runtime-state",payload:{type:"warning",error:err.code,project:err.project,text:"notification.warnings."+err.code},retain:true});
if (err.code === "project_not_found") {
log.warn(log._("storage.localfilesystem.projects.project-not-found",{project:err.project}));
} else {
log.warn(log._("nodes.flows.error",{message:err.toString()}));
}
throw err;
}
throw err;
});
}
function load(forceStart) {
@ -317,7 +328,12 @@ function start(type,diff,muteLog) {
}
}
events.emit("nodes-started");
events.emit("runtime-event",{id:"runtime-state",retain:true});
if (credentialsPendingReset === true) {
credentialsPendingReset = false;
} else {
events.emit("runtime-event",{id:"runtime-state",retain:true});
}
if (!muteLog) {
if (type !== "full") {