Merge pull request #17318 from overleaf/jpa-create-tokens-first

[web] create link-sharing tokens before enabling link-sharing

GitOrigin-RevId: 19a72d57623421681f0de3193572b916a5adeaa9
This commit is contained in:
Jakob Ackermann 2024-02-27 16:55:42 +00:00 committed by Copybot
parent 346ad10d2e
commit 642eea2de6

View file

@ -568,24 +568,31 @@ const EditorController = {
},
setPublicAccessLevel(projectId, newAccessLevel, callback) {
ProjectDetailsHandler.setPublicAccessLevel(
projectId,
newAccessLevel,
function (err) {
if (err) {
return callback(err)
}
EditorRealTimeController.emitToRoom(
projectId,
'project:publicAccessLevel:changed',
{ newAccessLevel }
)
if (newAccessLevel === PublicAccessLevels.TOKEN_BASED) {
ProjectDetailsHandler.ensureTokensArePresent(projectId, callback)
} else {
callback()
}
}
async.series(
[
cb => {
if (newAccessLevel === PublicAccessLevels.TOKEN_BASED) {
ProjectDetailsHandler.ensureTokensArePresent(projectId, cb)
} else {
cb()
}
},
cb =>
ProjectDetailsHandler.setPublicAccessLevel(
projectId,
newAccessLevel,
cb
),
cb => {
EditorRealTimeController.emitToRoom(
projectId,
'project:publicAccessLevel:changed',
{ newAccessLevel }
)
cb()
},
],
callback
)
},