Skip to content

Commit 1c30cd9

Browse files
Make small change to CLI (getodk#751)
1 parent 4cb99ba commit 1c30cd9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/task/account.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ const promoteUser = task.withContainer((container) => (email) => container.trans
3131

3232
// Given a User email and a plaintext password, finds and sets that User's password
3333
// to the given one.
34-
const setUserPassword = task.withContainer((container) => (email, password) => container.transacting(({ Users }) =>
34+
const setUserPassword = task.withContainer((container) => (email, password) => container.transacting(({ Sessions, Users }) =>
3535
Users.getByEmail(email)
3636
.then(getOrNotFound)
37-
.then((user) => Users.updatePassword(user, password))
37+
.then((user) => Promise.all([
38+
Users.updatePassword(user, password),
39+
Sessions.terminateByActorId(user.actorId)
40+
]))
3841
.then(success)));
3942

4043
module.exports = { createUser, promoteUser, setUserPassword };

test/integration/task/account.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ describe('task: accounts', () => {
8787
.then(() => setUserPassword('[email protected]', 'aoeu'))
8888
.catch((problem) => problem.problemCode.should.equal(400.21))));
8989

90+
it('should delete sessions', testTask(async ({ Sessions, Users }) => {
91+
const user = await Users.create(User.fromApi({
92+
93+
displayName: 'test user'
94+
}));
95+
const { token } = await Sessions.create(user.actor);
96+
(await Sessions.getByBearerToken(token)).isDefined().should.be.true();
97+
await setUserPassword('[email protected]', 'aoeuidhtns');
98+
(await Sessions.getByBearerToken(token)).isDefined().should.be.false();
99+
}));
100+
90101
it('should log an audit entry', testTask(({ Audits, Users }) =>
91102
Users.create(User.fromApi({ email: '[email protected]', displayName: 'test user' }))
92103
.then(() => setUserPassword('[email protected]', 'aoeuidhtns'))

0 commit comments

Comments
 (0)