diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index ac8d5563cb..4682372fb5 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -42,6 +42,8 @@ const PublicAccessLevels = require('../Authorization/PublicAccessLevels') const TagsHandler = require('../Tags/TagsHandler') const TutorialHandler = require('../Tutorial/TutorialHandler') const UserUpdater = require('../User/UserUpdater') +const { checkUserPermissions } = + require('../Authorization/PermissionsManager').promises /** * @typedef {import("./types").GetProjectsRequest} GetProjectsRequest @@ -596,10 +598,19 @@ const _ProjectController = { !showPersonalAccessToken && splitTestAssignments['personal-access-token'].variant === 'enabled' // `?personal-access-token=enabled` + let canUseAi + try { + await checkUserPermissions(user, ['use-ai']) + canUseAi = true + } catch (err) { + canUseAi = false + } + const showAiErrorAssistant = userId && Features.hasFeature('saas') && - (user.features?.aiErrorAssistant || user.alphaProgram) && + user.features?.aiErrorAssistant && + canUseAi && (privilegeLevel === PrivilegeLevels.READ_AND_WRITE || privilegeLevel === PrivilegeLevels.OWNER) diff --git a/services/web/app/src/router.js b/services/web/app/src/router.js index f1c876d26b..5c8f090d6c 100644 --- a/services/web/app/src/router.js +++ b/services/web/app/src/router.js @@ -509,6 +509,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) { RateLimiterMiddleware.rateLimit(openProjectRateLimiter, { params: ['Project_id'], }), + PermissionsController.useCapabilities(), AuthorizationMiddleware.ensureUserCanReadProject, ProjectController.loadEditor ) diff --git a/services/web/frontend/js/features/settings/components/labs-program-section.tsx b/services/web/frontend/js/features/settings/components/labs-program-section.tsx index cace463ddf..2420a68e7c 100644 --- a/services/web/frontend/js/features/settings/components/labs-program-section.tsx +++ b/services/web/frontend/js/features/settings/components/labs-program-section.tsx @@ -3,12 +3,7 @@ import { useUserContext } from '../../../shared/context/user-context' function LabsProgramSection() { const { t } = useTranslation() - const { labsProgram, alphaProgram } = useUserContext() - - // keeping alpha only as we test AI experiment in preparation for general labs release - if (!alphaProgram) { - return null - } + const { labsProgram } = useUserContext() const labsStatusText = labsProgram ? t('youre_a_member_of_overleaf_labs')