From 923969b38c8c43759ebc4242aa94c9bf46e869f2 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Tue, 30 Oct 2018 16:15:48 +0700 Subject: [PATCH] Removed user_id constraint when upserting session (#10085) no-issue This is to stop an issue when creating a session, if you already have an existing session --- core/server/models/session.js | 2 +- core/test/unit/models/session_spec.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/core/server/models/session.js b/core/server/models/session.js index 6b9b2d02f0..f65d031d3e 100644 --- a/core/server/models/session.js +++ b/core/server/models/session.js @@ -53,7 +53,7 @@ const Session = ghostBookshelf.Model.extend({ const sessionId = options.session_id; const sessionData = data.session_data; const userId = sessionData.user_id; - return this.findOne({session_id: sessionId, user_id: userId}, options) + return this.findOne({session_id: sessionId}, options) .then((model) => { if (model) { return this.edit({ diff --git a/core/test/unit/models/session_spec.js b/core/test/unit/models/session_spec.js index 2ec2710ebf..4048d0046b 100644 --- a/core/test/unit/models/session_spec.js +++ b/core/test/unit/models/session_spec.js @@ -175,8 +175,7 @@ describe('Unit: models/session', function () { should.equal(filterOptionsStub.args[0][1], 'upsert'); should.deepEqual(findOneStub.args[0][0], { - session_id, - user_id: data.session_data.user_id + session_id }); should.equal(findOneStub.args[0][1], filteredOptions); @@ -215,8 +214,7 @@ describe('Unit: models/session', function () { should.equal(filterOptionsStub.args[0][1], 'upsert'); should.deepEqual(findOneStub.args[0][0], { - session_id, - user_id: data.session_data.user_id + session_id }); should.equal(findOneStub.args[0][1], filteredOptions);