mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-08 08:39:03 +02:00
Merge pull request #5330 from overleaf/ab-analytics-middleware-passport-id
Fix passport user id reference in analytics ID middleware GitOrigin-RevId: 7d237a6f358b5632c672aafd6e1e72ab53d8650f
This commit is contained in:
@@ -232,7 +232,7 @@ async function analyticsIdMiddleware(req, res, next) {
|
||||
|
||||
if (sessionUser) {
|
||||
// ensure `session.analyticsId` is set to the user's `analyticsId`, and fallback to their `userId` for pre-analyticsId users
|
||||
session.analyticsId = sessionUser.analyticsId || sessionUser.userId
|
||||
session.analyticsId = sessionUser.analyticsId || sessionUser._id
|
||||
} else if (!session.analyticsId) {
|
||||
// generate an `analyticsId` if needed
|
||||
session.analyticsId = uuid.v4()
|
||||
|
||||
@@ -198,7 +198,7 @@ describe('AnalyticsManager', function () {
|
||||
|
||||
it('sets session.analyticsId with a logged in user in session having an analyticsId', async function () {
|
||||
this.req.session.user = {
|
||||
userId: this.userId,
|
||||
_id: this.userId,
|
||||
analyticsId: this.analyticsId,
|
||||
}
|
||||
await this.AnalyticsManager.analyticsIdMiddleware(
|
||||
@@ -211,7 +211,7 @@ describe('AnalyticsManager', function () {
|
||||
|
||||
it('sets session.analyticsId with a legacy user session without an analyticsId', async function () {
|
||||
this.req.session.user = {
|
||||
userId: this.userId,
|
||||
_id: this.userId,
|
||||
analyticsId: undefined,
|
||||
}
|
||||
await this.AnalyticsManager.analyticsIdMiddleware(
|
||||
@@ -224,7 +224,7 @@ describe('AnalyticsManager', function () {
|
||||
|
||||
it('updates session.analyticsId with a legacy user session without an analyticsId if different', async function () {
|
||||
this.req.session.user = {
|
||||
userId: this.userId,
|
||||
_id: this.userId,
|
||||
analyticsId: undefined,
|
||||
}
|
||||
this.req.analyticsId = 'foo'
|
||||
@@ -238,7 +238,7 @@ describe('AnalyticsManager', function () {
|
||||
|
||||
it('does not update session.analyticsId with a legacy user session without an analyticsId if same', async function () {
|
||||
this.req.session.user = {
|
||||
userId: this.userId,
|
||||
_id: this.userId,
|
||||
analyticsId: undefined,
|
||||
}
|
||||
this.req.analyticsId = this.userId
|
||||
|
||||
Reference in New Issue
Block a user