diff --git a/server/lib/session/session.get.js b/server/lib/session/session.get.js index 90fe07e1eb..415c6afa84 100644 --- a/server/lib/session/session.get.js +++ b/server/lib/session/session.get.js @@ -9,6 +9,7 @@ const DEFAULT_OPTIONS = { const FIELDS = [ 'id', + 'user_id', 'token_type', 'scope', 'valid_until', @@ -37,6 +38,7 @@ async function get(userId, options) { order: [[optionsWithDefault.order_by, optionsWithDefault.order_dir]], where: { revoked: false, + user_id: userId, }, }); diff --git a/server/test/security/session.test.js b/server/test/security/session.test.js new file mode 100644 index 0000000000..fbd0dc791b --- /dev/null +++ b/server/test/security/session.test.js @@ -0,0 +1,17 @@ +const { expect } = require('chai'); +const { authenticatedRequest } = require('../controllers/request.test'); + +describe('/api/v1/session/', () => { + it('should return the sessionIds of current user', async () => { + await authenticatedRequest + .get('/api/v1/session') + .expect('Content-Type', /json/) + .expect(200) + .then(async (res) => { + const userId = '0cd30aef-9c4e-4a23-88e3-3547971296e5'; + res.body.forEach((u) => { + expect(u.user_id).to.be.equal(userId); + }); + }); + }); +});