fix: prevent integrity signature creation while masquerading (#665)

This commit is contained in:
Bianca Severino
2021-10-06 11:26:04 -04:00
committed by GitHub
parent 0889b17e85
commit 0bc7faaa56
3 changed files with 12 additions and 6 deletions

View File

@@ -5,19 +5,19 @@ import { getConfig, history } from '@edx/frontend-platform';
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { ActionRow, Alert, Button } from '@edx/paragon';
import { useModel } from '../../../../generic/model-store';
import { saveIntegritySignature } from '../../../data';
import messages from './messages';
function HonorCode({ intl, courseId }) {
const dispatch = useDispatch();
const { isMasquerading } = useModel('coursewareMeta', courseId);
const siteName = getConfig().SITE_NAME;
const honorCodeUrl = `${process.env.TERMS_OF_SERVICE_URL}#honor-code`;
const honorCodeUrl = `${getConfig().TERMS_OF_SERVICE_URL}#honor-code`;
const handleCancel = () => history.push(`/course/${courseId}/home`);
const handleAgree = () => {
dispatch(saveIntegritySignature(courseId));
};
const handleAgree = () => dispatch(saveIntegritySignature(courseId, isMasquerading));
return (
<Alert variant="light" aria-live="off">

View File

@@ -303,10 +303,15 @@ export function saveSequencePosition(courseId, sequenceId, activeUnitIndex) {
};
}
export function saveIntegritySignature(courseId) {
export function saveIntegritySignature(courseId, isMasquerading) {
return async (dispatch) => {
try {
await postIntegritySignature(courseId);
// If the request is made by a staff user masquerading as a learner,
// don't actually create a signature for them on the backend. Only
// frontend state will be updated.
if (!isMasquerading) {
await postIntegritySignature(courseId);
}
dispatch(updateModel({
modelType: 'coursewareMeta',
model: {

View File

@@ -101,6 +101,7 @@ initialize({
SUPPORT_URL_CALCULATOR_MATH: process.env.SUPPORT_URL_CALCULATOR_MATH || null,
SUPPORT_URL_ID_VERIFICATION: process.env.SUPPORT_URL_ID_VERIFICATION || null,
SUPPORT_URL_VERIFIED_CERTIFICATE: process.env.SUPPORT_URL_VERIFIED_CERTIFICATE || null,
TERMS_OF_SERVICE_URL: process.env.TERMS_OF_SERVICE_URL || null,
TWITTER_HASHTAG: process.env.TWITTER_HASHTAG || null,
TWITTER_URL: process.env.TWITTER_URL || null,
}, 'LearnerAppConfig');