Merge pull request #12901 from overleaf/msm-oauth-token-flags

[web] Feature flags for Personal Access Tokens

GitOrigin-RevId: cb359b7c41d8875ebae7d78a8839528bc4adc04c
This commit is contained in:
Miguel Serrano 2023-05-08 09:58:00 +02:00 committed by Copybot
parent f2f7f6b7d6
commit c2dce961b9
5 changed files with 17 additions and 1 deletions

View file

@ -1317,6 +1317,10 @@ const ProjectController = {
onboardingVideoTourAssignment.variant === 'active' &&
req.session.justRegistered
const showPersonalAccessToken =
!Features.hasFeature('saas') ||
req.query?.personal_access_token === 'true'
const template =
detachRole === 'detached'
? 'project/editor_detached'
@ -1407,6 +1411,7 @@ const ProjectController = {
richTextVariant: richTextAssignment.variant,
showOnboardingVideoTour,
historyViewReact: historyViewAssignment.variant === 'react',
showPersonalAccessToken,
})
timer.done()
}

View file

@ -8,6 +8,7 @@ const SessionManager = require('../Authentication/SessionManager')
const NewsletterManager = require('../Newsletter/NewsletterManager')
const _ = require('lodash')
const { expressify } = require('../../util/promises')
const Features = require('../../infrastructure/Features')
async function settingsPage(req, res) {
const userId = SessionManager.getLoggedInUserId(req.session)
@ -64,6 +65,10 @@ async function settingsPage(req, res) {
res.redirect('/')
)
}
const showPersonalAccessToken =
!Features.hasFeature('saas') || req.query?.personal_access_token === 'true'
res.render('user/settings', {
title: 'account_settings',
user: {
@ -106,6 +111,7 @@ async function settingsPage(req, res) {
ssoErrorMessage,
thirdPartyIds: UserPagesController._restructureThirdPartyIds(user),
projectSyncSuccessMessage,
showPersonalAccessToken,
})
}

View file

@ -41,6 +41,7 @@ meta(name="ol-showTemplatesServerPro", data-type="boolean" content=showTemplates
meta(name="ol-showCM6SwitchAwaySurvey", data-type="boolean" content=showCM6SwitchAwaySurvey)
meta(name="ol-richTextVariant" content=richTextVariant)
meta(name="ol-showOnboardingVideoTour", data-type="boolean" content=showOnboardingVideoTour)
meta(name="ol-showPersonalAccessToken", data-type="boolean" content=showPersonalAccessToken)
if (richTextVariant === 'cm6')
meta(name="ol-mathJax3Path" content=mathJax3Path)

View file

@ -22,7 +22,7 @@ block append meta
meta(name="ol-dropbox" data-type="json" content=dropbox)
meta(name="ol-github" data-type="json" content=github)
meta(name="ol-projectSyncSuccessMessage", content=projectSyncSuccessMessage)
meta(name="ol-showPersonalAccessToken", data-type="boolean" content=showPersonalAccessToken)
block content
main.content.content-alt#settings-page-root

View file

@ -67,6 +67,9 @@ describe('UserPagesController', function () {
_getRedirectFromSession: sinon.stub(),
setRedirectInSession: sinon.stub(),
}
this.Features = {
hasFeature: sinon.stub().returns(false),
}
this.UserPagesController = SandboxedModule.require(modulePath, {
requires: {
'@overleaf/settings': this.settings,
@ -76,6 +79,7 @@ describe('UserPagesController', function () {
'../Errors/ErrorController': this.ErrorController,
'../Authentication/AuthenticationController':
this.AuthenticationController,
'../../infrastructure/Features': this.Features,
'../Authentication/SessionManager': this.SessionManager,
request: (this.request = sinon.stub()),
},