mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #12297 from overleaf/jpa-primary-email-check-saas
[web] disable primary email check in Server CE/Pro GitOrigin-RevId: be40160aecae7f19780a67e5cdd9356be232ee22
This commit is contained in:
parent
d9e0215aee
commit
e6a8f3d04f
4 changed files with 97 additions and 7 deletions
5
server-ce/hotfix/3.5.4/Dockerfile
Normal file
5
server-ce/hotfix/3.5.4/Dockerfile
Normal file
|
@ -0,0 +1,5 @@
|
|||
FROM sharelatex/sharelatex:3.5.3
|
||||
|
||||
# Patch: run primary email check in saas only
|
||||
COPY primary_email_check_saas.patch .
|
||||
RUN patch -p0 < primary_email_check_saas.patch
|
10
server-ce/hotfix/3.5.4/primary_email_check_saas.patch
Normal file
10
server-ce/hotfix/3.5.4/primary_email_check_saas.patch
Normal file
|
@ -0,0 +1,10 @@
|
|||
--- services/web/app/src/Features/Project/ProjectController.js
|
||||
+++ services/web/app/src/Features/Project/ProjectController.js
|
||||
@@ -535,6 +535,7 @@ const ProjectController = {
|
||||
|
||||
if (
|
||||
user &&
|
||||
+ Features.hasFeature('saas') &&
|
||||
UserPrimaryEmailCheckHandler.requiresPrimaryEmailCheck(user)
|
||||
) {
|
||||
return res.redirect('/user/emails/primary-email-check')
|
|
@ -535,6 +535,7 @@ const ProjectController = {
|
|||
|
||||
if (
|
||||
user &&
|
||||
Features.hasFeature('saas') &&
|
||||
UserPrimaryEmailCheckHandler.requiresPrimaryEmailCheck(user)
|
||||
) {
|
||||
return res.redirect('/user/emails/primary-email-check')
|
||||
|
|
|
@ -6,12 +6,6 @@ const Features = require('../../../app/src/infrastructure/Features')
|
|||
describe('PrimaryEmailCheck', function () {
|
||||
let userHelper
|
||||
|
||||
before(async function () {
|
||||
if (!Features.hasFeature('saas')) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(async function () {
|
||||
userHelper = await UserHelper.createUser()
|
||||
userHelper = await UserHelper.loginUser(
|
||||
|
@ -19,7 +13,87 @@ describe('PrimaryEmailCheck', function () {
|
|||
)
|
||||
})
|
||||
|
||||
describe('redirections', function () {
|
||||
describe('redirections in Server CE/Pro', function () {
|
||||
before(async function () {
|
||||
if (Features.hasFeature('saas')) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
describe('when the user has signed up recently', function () {
|
||||
it("shouldn't be redirected from project list to the primary email check page", async function () {
|
||||
const response = await userHelper.fetch('/project')
|
||||
expect(response.status).to.equal(200)
|
||||
})
|
||||
|
||||
it('should be redirected from the primary email check page to the project list', async function () {
|
||||
const response = await userHelper.fetch(
|
||||
'/user/emails/primary-email-check'
|
||||
)
|
||||
expect(response.status).to.equal(302)
|
||||
expect(response.headers.get('location')).to.equal(
|
||||
UserHelper.url('/project').toString()
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the user has checked their email recently', function () {
|
||||
beforeEach(async function () {
|
||||
const time = Date.now() - Settings.primary_email_check_expiration * 0.5
|
||||
await UserHelper.updateUser(userHelper.user._id, {
|
||||
$set: { lastPrimaryEmailCheck: new Date(time) },
|
||||
})
|
||||
})
|
||||
|
||||
it("shouldn't be redirected from project list to the primary email check page", async function () {
|
||||
const response = await userHelper.fetch('/project')
|
||||
expect(response.status).to.equal(200)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the user has confirmed their primary email recently', function () {
|
||||
beforeEach(async function () {
|
||||
// the user should check again their email according to `lastPrimaryEmailCheck` timestamp, but the behaviour is
|
||||
// overridden by email confirmation
|
||||
const time = Date.now() - Settings.primary_email_check_expiration * 2
|
||||
await UserHelper.updateUser(userHelper.user._id, {
|
||||
$set: { lastPrimaryEmailCheck: new Date(time) },
|
||||
})
|
||||
|
||||
await userHelper.confirmEmail(
|
||||
userHelper.user._id,
|
||||
userHelper.user.email
|
||||
)
|
||||
})
|
||||
|
||||
it("shouldn't be redirected from project list to the primary email check page", async function () {
|
||||
const response = await userHelper.fetch('/project')
|
||||
expect(response.status).to.equal(200)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the user has signed for longer than the email check expiration period', function () {
|
||||
beforeEach(async function () {
|
||||
const time = Date.now() - Settings.primary_email_check_expiration * 2
|
||||
await UserHelper.updateUser(userHelper.user._id, {
|
||||
$set: { lastPrimaryEmailCheck: new Date(time) },
|
||||
})
|
||||
})
|
||||
|
||||
it("shouldn't be redirected from project list to the primary email check page", async function () {
|
||||
const response = await userHelper.fetch('/project')
|
||||
expect(response.status).to.equal(200)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('redirections in SAAS', function () {
|
||||
before(async function () {
|
||||
if (!Features.hasFeature('saas')) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
describe('when the user has signed up recently', function () {
|
||||
it("shouldn't be redirected from project list to the primary email check page", async function () {
|
||||
const response = await userHelper.fetch('/project')
|
||||
|
|
Loading…
Reference in a new issue