From 884d766afe60da51caa82959c7f62111f5e5297f Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Sun, 1 Mar 2015 12:33:00 +0000 Subject: [PATCH] More serverside notificaiton HTML fixes refs #4964, #4969 --- core/client/controllers/settings/navigation.js | 4 +++- core/client/routes/application.js | 5 +++++ core/server/models/user.js | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/client/controllers/settings/navigation.js b/core/client/controllers/settings/navigation.js index 6b634b0495..ef798f83c5 100644 --- a/core/client/controllers/settings/navigation.js +++ b/core/client/controllers/settings/navigation.js @@ -100,11 +100,13 @@ NavigationController = Ember.Controller.extend({ blogUrl = this.get('config').blogUrl, blogUrlRegex = new RegExp('^' + blogUrl + '(.*)', 'i'), navItems = this.get('navigationItems'), + message = 'One of your navigation items has an empty label. ' + + '
Please enter a new label or delete the item before saving.', match; // Don't save if there's a blank label. if (navItems.find(function (item) { return !item.get('isComplete') && !item.get('last');})) { - self.notifications.showErrors(['One of your navigation items has an empty label.
Please enter a new label or delete the item before saving.']); + self.notifications.showErrors([message.htmlSafe()]); return; } diff --git a/core/client/routes/application.js b/core/client/routes/application.js index 986d87ccc4..2b77facdd5 100644 --- a/core/client/routes/application.js +++ b/core/client/routes/application.js @@ -55,6 +55,11 @@ ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, Shortcut sessionAuthenticationFailed: function (error) { if (error.errors) { + // These are server side errors, which can be marked as htmlSafe + error.errors.forEach(function (err) { + err.message = err.message.htmlSafe(); + }); + this.notifications.showErrors(error.errors); } else { // connection errors don't return proper status message, only req.body diff --git a/core/server/models/user.js b/core/server/models/user.js index 17797ebc88..e217f0ac5d 100644 --- a/core/server/models/user.js +++ b/core/server/models/user.js @@ -644,7 +644,7 @@ User = ghostBookshelf.Model.extend({ if (!matched) { return Promise.resolve(self.setWarning(user, {validate: false})).then(function (remaining) { s = (remaining > 1) ? 's' : ''; - return Promise.reject(new errors.UnauthorizedError('Your password is incorrect.
' + + return Promise.reject(new errors.UnauthorizedError('Your password is incorrect.
' + remaining + ' attempt' + s + ' remaining!')); // Use comma structure, not .catch, because we don't want to catch incorrect passwords