Skip to content

Commit

Permalink
feat: add DISABLE_SELF_ENROLLMENT run time configuration variable to …
Browse files Browse the repository at this point in the history
…avoid self enrollments.
  • Loading branch information
Jacatove committed Nov 24, 2023
1 parent 7a2c806 commit 94418ba
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ TERMS_OF_SERVICE_URL=''
TWITTER_HASHTAG=''
TWITTER_URL=''
USER_INFO_COOKIE_NAME=''
DISABLE_SELF_ENROLLMENT='false'
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ TWITTER_HASHTAG='myedxjourney'
TWITTER_URL='https://twitter.com/edXOnline'
USER_INFO_COOKIE_NAME='edx-user-info'
SESSION_COOKIE_DOMAIN='localhost'
DISABLE_SELF_ENROLLMENT='false'
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ TERMS_OF_SERVICE_URL='https://www.edx.org/edx-terms-service'
TWITTER_HASHTAG='myedxjourney'
TWITTER_URL='https://twitter.com/edXOnline'
USER_INFO_COOKIE_NAME='edx-user-info'
DISABLE_SELF_ENROLLMENT='false'
3 changes: 2 additions & 1 deletion src/alerts/enrollment-alert/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {
useContext, useMemo,
} from 'react';
import { AppContext } from '@edx/frontend-platform/react';
import { getConfig } from '@edx/frontend-platform';

import { useAlert } from '../../generic/user-messages';
import { useModel } from '../../generic/model-store';
Expand All @@ -23,7 +24,7 @@ export function useEnrollmentAlert(courseId) {
*/
const isVisible = !enrolledUser && authenticatedUser !== null && privateOutline;
const payload = {
canEnroll: outline && outline.enrollAlert ? outline.enrollAlert.canEnroll : false,
canEnroll: getConfig().DISABLE_SELF_ENROLLMENT !== 'true' && outline && outline.enrollAlert ? outline.enrollAlert.canEnroll : false,
courseId,
extraText: outline && outline.enrollAlert ? outline.enrollAlert.extraText : '',
isStaff: course && course.isStaff,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable import/prefer-default-export */
import React, { useContext, useMemo } from 'react';
import { AppContext } from '@edx/frontend-platform/react';
import { getConfig } from '@edx/frontend-platform';
import { ALERT_TYPES, useAlert } from '../../../../generic/user-messages';
import { useModel } from '../../../../generic/model-store';

Expand All @@ -20,7 +21,7 @@ export function usePrivateCourseAlert(courseId) {
const isVisible = !enrolledUser && (privateOutline || authenticatedUser !== null);
const payload = {
anonymousUser: authenticatedUser === null,
canEnroll: outline && outline.enrollAlert ? outline.enrollAlert.canEnroll : false,
canEnroll: getConfig().DISABLE_SELF_ENROLLMENT !== 'true' && outline && outline.enrollAlert ? outline.enrollAlert.canEnroll : false,
courseId,
};

Expand Down

0 comments on commit 94418ba

Please sign in to comment.