From 478ed3c522039ffdc462d516ac9057aa90d0d498 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 18 Aug 2015 15:22:28 -0700 Subject: [PATCH] fix should toString userId's --- server/boot/a-extendUserIdent.js | 2 +- server/middlewares/add-return-to.js | 24 ++++++++++++++++++++++-- server/views/account/account.jade | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/server/boot/a-extendUserIdent.js b/server/boot/a-extendUserIdent.js index f5f5e9ebc7..1fac91d85e 100644 --- a/server/boot/a-extendUserIdent.js +++ b/server/boot/a-extendUserIdent.js @@ -47,7 +47,7 @@ export default function({ models }) { modified }); } - if (identity.userId !== userId) { + if (identity.userId.toString() !== userId.toString()) { return Observable.throw( new Error('An account is already linked to that profile') ); diff --git a/server/middlewares/add-return-to.js b/server/middlewares/add-return-to.js index 9e9522b1ad..5fbd19c39d 100644 --- a/server/middlewares/add-return-to.js +++ b/server/middlewares/add-return-to.js @@ -1,10 +1,30 @@ +const pathsOfNoReturn = [ + 'link', + 'auth', + 'login', + 'logout', + 'signin', + 'signup', + 'fonts', + 'favicon', + 'js', + 'css' +]; + +const pathsOfNoReturnRegex = new RegExp(pathsOfNoReturn.join('|'), 'i'); + export default function addReturnToUrl() { return function(req, res, next) { // Remember original destination before login. var path = req.path.split('/')[1]; - if (/auth|login|logout|signin|signup|fonts|favicon/i.test(path)) { + + if (req.method !== 'GET') { return next(); - } else if (/\/stories\/\w+/i.test(req.path)) { + } + if (pathsOfNoReturnRegex.test(path)) { + return next(); + } + if (/\/stories\/\w+/i.test(req.path)) { return next(); } req.session.returnTo = req.path; diff --git a/server/views/account/account.jade b/server/views/account/account.jade index 549f416073..44bcca998b 100644 --- a/server/views/account/account.jade +++ b/server/views/account/account.jade @@ -2,7 +2,7 @@ extends ../layout block content script. var challengeName = 'Account View' - .panel.panel-info(ng-controller="profileValidationController") + .panel.panel-info .panel-heading.text-center Manage your account here .panel-body .row