mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
[web] throw early in UserCreator.createNewUser with missing analyticsId (#34664)
* [web] throw early in UserCreator.createNewUser with missing analyticsId * [migrations] rerun back-fill of db.users.analyticsId GitOrigin-RevId: eabf16326192fca4dbea00ad643cee4315c426c6
This commit is contained in:
@@ -128,6 +128,7 @@ function registerExternalAuthAdmin(authMethod) {
|
||||
password: crypto.randomBytes(32).toString('hex'),
|
||||
first_name: email,
|
||||
last_name: '',
|
||||
analyticsId: crypto.randomUUID(),
|
||||
}
|
||||
logger.debug(
|
||||
{ email, authMethod },
|
||||
@@ -212,7 +213,7 @@ async function registerAdmin(req, res) {
|
||||
.json({ message: { type: 'error', text: invalidPassword.message } })
|
||||
}
|
||||
|
||||
const body = { email, password }
|
||||
const body = { email, password, analyticsId: crypto.randomUUID() }
|
||||
|
||||
const user = await UserRegistrationHandler.promises.registerNewUser(body)
|
||||
|
||||
|
||||
@@ -71,6 +71,19 @@ describe('LaunchpadController', function () {
|
||||
})
|
||||
)
|
||||
|
||||
vi.doMock('crypto', () => ({
|
||||
default: (ctx.crypto = {
|
||||
randomUUID: sinon
|
||||
.stub()
|
||||
.returns('8055c676-bcc7-4e64-a66f-8069f9a0bd92'),
|
||||
randomBytes: sinon.stub().returns({
|
||||
toString: () => {
|
||||
return (ctx.password = 'mock-password123')
|
||||
},
|
||||
}),
|
||||
}),
|
||||
}))
|
||||
|
||||
ctx.LaunchpadController = (await import(modulePath)).default
|
||||
|
||||
ctx.email = 'bob@smith.com'
|
||||
@@ -344,7 +357,11 @@ describe('LaunchpadController', function () {
|
||||
1
|
||||
)
|
||||
ctx.UserRegistrationHandler.promises.registerNewUser
|
||||
.calledWith({ email: ctx.email, password: ctx.password })
|
||||
.calledWith({
|
||||
email: ctx.email,
|
||||
password: ctx.password,
|
||||
analyticsId: '8055c676-bcc7-4e64-a66f-8069f9a0bd92',
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
@@ -603,7 +620,11 @@ describe('LaunchpadController', function () {
|
||||
1
|
||||
)
|
||||
ctx.UserRegistrationHandler.promises.registerNewUser
|
||||
.calledWith({ email: ctx.email, password: ctx.password })
|
||||
.calledWith({
|
||||
email: ctx.email,
|
||||
password: ctx.password,
|
||||
analyticsId: '8055c676-bcc7-4e64-a66f-8069f9a0bd92',
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
@@ -649,7 +670,11 @@ describe('LaunchpadController', function () {
|
||||
1
|
||||
)
|
||||
ctx.UserRegistrationHandler.promises.registerNewUser
|
||||
.calledWith({ email: ctx.email, password: ctx.password })
|
||||
.calledWith({
|
||||
email: ctx.email,
|
||||
password: ctx.password,
|
||||
analyticsId: '8055c676-bcc7-4e64-a66f-8069f9a0bd92',
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
@@ -693,7 +718,11 @@ describe('LaunchpadController', function () {
|
||||
1
|
||||
)
|
||||
ctx.UserRegistrationHandler.promises.registerNewUser
|
||||
.calledWith({ email: ctx.email, password: ctx.password })
|
||||
.calledWith({
|
||||
email: ctx.email,
|
||||
password: ctx.password,
|
||||
analyticsId: '8055c676-bcc7-4e64-a66f-8069f9a0bd92',
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user