-
-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Count active browser sessions per user (#8736)
Show info on how many devices a user is logged in to an admin.
- Loading branch information
Showing
9 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ beforeAll(async () => { | |
experimental: { | ||
flags: { | ||
strictSchemaValidation: true, | ||
showUserDeviceCount: true, | ||
}, | ||
}, | ||
}); | ||
|
@@ -428,3 +429,36 @@ test('creates user with email md5 hash', async () => { | |
|
||
expect(user.email_hash).toBe(expectedHash); | ||
}); | ||
|
||
test('should return number of sessions per user', async () => { | ||
const user = await userStore.insert({ email: '[email protected]' }); | ||
await sessionStore.insertSession({ | ||
sid: '1', | ||
sess: { user: { id: user.id } }, | ||
}); | ||
await sessionStore.insertSession({ | ||
sid: '2', | ||
sess: { user: { id: user.id } }, | ||
}); | ||
|
||
const user2 = await userStore.insert({ email: '[email protected]' }); | ||
await sessionStore.insertSession({ | ||
sid: '3', | ||
sess: { user: { id: user2.id } }, | ||
}); | ||
|
||
const response = await app.request.get(`/api/admin/user-admin`).expect(200); | ||
|
||
expect(response.body).toMatchObject({ | ||
users: expect.arrayContaining([ | ||
expect.objectContaining({ | ||
email: '[email protected]', | ||
activeSessions: 2, | ||
}), | ||
expect.objectContaining({ | ||
email: '[email protected]', | ||
activeSessions: 1, | ||
}), | ||
]), | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters