mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Log error if settings unavailable when saving user settings
Fixes #1645
This commit is contained in:
parent
f4c2938b41
commit
52d9578a19
@ -88,13 +88,19 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
var currentSettings = settings.getUserSettings(username)||{};
|
var currentSettings = settings.getUserSettings(username)||{};
|
||||||
currentSettings = extend(currentSettings, req.body);
|
currentSettings = extend(currentSettings, req.body);
|
||||||
settings.setUserSettings(username, currentSettings).then(function() {
|
try {
|
||||||
log.audit({event: "settings.update",username:username},req);
|
settings.setUserSettings(username, currentSettings).then(function() {
|
||||||
res.status(204).end();
|
log.audit({event: "settings.update",username:username},req);
|
||||||
}).catch(function(err) {
|
res.status(204).end();
|
||||||
|
}).catch(function(err) {
|
||||||
|
log.audit({event: "settings.update",username:username,error:err.code||"unexpected_error",message:err.toString()},req);
|
||||||
|
res.status(400).json({error:err.code||"unexpected_error", message:err.toString()});
|
||||||
|
});
|
||||||
|
} catch(err) {
|
||||||
|
log.warn(log._("settings.user-not-available",{message:log._("settings.not-available")}));
|
||||||
log.audit({event: "settings.update",username:username,error:err.code||"unexpected_error",message:err.toString()},req);
|
log.audit({event: "settings.update",username:username,error:err.code||"unexpected_error",message:err.toString()},req);
|
||||||
res.status(400).json({error:err.code||"unexpected_error", message:err.toString()});
|
res.status(400).json({error:err.code||"unexpected_error", message:err.toString()});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"settings": {
|
"settings": {
|
||||||
|
"user-not-available": "Cannot save user settings: __message__",
|
||||||
"not-available": "Settings not available",
|
"not-available": "Settings not available",
|
||||||
"property-read-only": "Property '__prop__' is read-only"
|
"property-read-only": "Property '__prop__' is read-only"
|
||||||
},
|
},
|
||||||
|
@ -173,6 +173,9 @@ var persistentSettings = {
|
|||||||
return clone(userSettings[username]);
|
return clone(userSettings[username]);
|
||||||
},
|
},
|
||||||
setUserSettings: function(username,settings) {
|
setUserSettings: function(username,settings) {
|
||||||
|
if (globalSettings === null) {
|
||||||
|
throw new Error(log._("settings.not-available"));
|
||||||
|
}
|
||||||
var current = userSettings[username];
|
var current = userSettings[username];
|
||||||
userSettings[username] = settings;
|
userSettings[username] = settings;
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user