Skip to content

Commit

Permalink
Merge pull request #541 from edx/MST-1130-remove-verified-name-waffle…
Browse files Browse the repository at this point in the history
…-flag

feat: Remove Use of Verified Name Enabled Flag
  • Loading branch information
MichaelRoytman authored Nov 1, 2021
2 parents 449e4c0 + e109e50 commit a18daec
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 441 deletions.
18 changes: 7 additions & 11 deletions src/account-settings/AccountSettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ class AccountSettingsPage extends React.Component {
renderFullNameHelpText = (status) => {
if (
!this.props.verifiedNameHistory
|| !this.props.verifiedNameEnabled
) {
return this.props.intl.formatMessage(messages['account.settings.field.full.name.help.text']);
}
Expand Down Expand Up @@ -471,7 +470,7 @@ class AccountSettingsPage extends React.Component {
// Show State field only if the country is US (could include Canada later)
const showState = this.props.formValues.country === COUNTRY_WITH_STATES;

const { verifiedName, verifiedNameEnabled } = this.props;
const { verifiedName } = this.props;

const timeZoneOptions = this.getLocalizedTimeZoneOptions(
this.props.timeZoneOptions,
Expand All @@ -484,7 +483,7 @@ class AccountSettingsPage extends React.Component {
<>
<div className="account-section" id="basic-information" ref={this.navLinkRefs['#basic-information']}>
{
verifiedNameEnabled && this.props.mostRecentVerifiedName
this.props.mostRecentVerifiedName
&& this.renderVerifiedNameMessage(this.props.mostRecentVerifiedName)
}

Expand Down Expand Up @@ -512,8 +511,7 @@ class AccountSettingsPage extends React.Component {
name="name"
type="text"
value={
verifiedNameEnabled
&& verifiedName?.status === 'submitted'
verifiedName?.status === 'submitted'
&& this.props.formValues.pending_name_change
? this.props.formValues.pending_name_change
: this.props.formValues.name
Expand All @@ -525,22 +523,22 @@ class AccountSettingsPage extends React.Component {
: this.renderEmptyStaticFieldMessage()
}
helpText={
verifiedNameEnabled && verifiedName
verifiedName
? this.renderFullNameHelpText(verifiedName.status)
: this.props.intl.formatMessage(messages['account.settings.field.full.name.help.text'])
}
isEditable={
verifiedNameEnabled && verifiedName
verifiedName
? this.isEditable('verifiedName') && this.isEditable('name')
: this.isEditable('name')
}
isGrayedOut={
verifiedNameEnabled && verifiedName && !this.isEditable('verifiedName')
verifiedName && !this.isEditable('verifiedName')
}
onChange={this.handleEditableFieldChange}
onSubmit={this.handleSubmitProfileName}
/>
{verifiedNameEnabled && verifiedName
{verifiedName
&& (
<EditableField
name="verified_name"
Expand Down Expand Up @@ -887,7 +885,6 @@ AccountSettingsPage.propTypes = {
nameChangeModal: PropTypes.shape({
formId: PropTypes.string,
}),
verifiedNameEnabled: PropTypes.bool,
verifiedName: PropTypes.shape({
verified_name: PropTypes.string,
status: PropTypes.string,
Expand Down Expand Up @@ -924,7 +921,6 @@ AccountSettingsPage.defaultProps = {
isActive: true,
secondary_email_enabled: false,
nameChangeModal: {},
verifiedNameEnabled: false,
verifiedName: null,
mostRecentVerifiedName: {},
verifiedNameHistory: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ function CertificatePreference({
originalVerifiedName,
saveState,
useVerifiedNameForCerts,
verifiedNameEnabled,
}) {
if (!verifiedNameEnabled || !originalVerifiedName) {
if (!originalVerifiedName) {
// If the user doesn't have an approved verified name, do not display this component
return null;
}
Expand Down Expand Up @@ -161,15 +160,13 @@ CertificatePreference.propTypes = {
originalVerifiedName: PropTypes.string,
saveState: PropTypes.string,
useVerifiedNameForCerts: PropTypes.bool,
verifiedNameEnabled: PropTypes.bool,
};

CertificatePreference.defaultProps = {
originalFullName: '',
originalVerifiedName: '',
saveState: null,
useVerifiedNameForCerts: false,
verifiedNameEnabled: false,
};

export default connect(certPreferenceSelector)(injectIntl(CertificatePreference));
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe('NameChange', () => {
originalVerifiedName: 'edX Verified',
saveState: null,
useVerifiedNameForCerts: false,
verifiedNameEnabled: true,
intl: {},
};

Expand Down
1 change: 0 additions & 1 deletion src/account-settings/data/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const defaultState = {
verifiedName: null,
mostRecentVerifiedName: {},
verifiedNameHistory: {},
verifiedNameEnabled: false,
};

const reducer = (state = defaultState, action) => {
Expand Down
7 changes: 0 additions & 7 deletions src/account-settings/data/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const verifiedNameSettingsSelector = createSelector(
accountSettingsSelector,
accountSettings => ({
history: accountSettings.verifiedNameHistory.results,
verifiedNameEnabled: accountSettings?.verifiedNameHistory.verified_name_enabled,
useVerifiedNameForCerts: accountSettings?.verifiedNameHistory.use_verified_name_for_certs,
}),
);
Expand Down Expand Up @@ -229,7 +228,6 @@ export const accountSettingsPageSelector = createSelector(
mostRecentApprovedVerifiedNameValueSelector,
mostRecentVerifiedNameSelector,
sortedVerifiedNameHistorySelector,
verifiedNameSettingsSelector,
(
accountSettings,
siteLanguageOptions,
Expand All @@ -247,7 +245,6 @@ export const accountSettingsPageSelector = createSelector(
verifiedName,
mostRecentVerifiedName,
verifiedNameHistory,
verifiedNameSettings,
) => ({
siteLanguageOptions,
siteLanguage,
Expand All @@ -268,19 +265,16 @@ export const accountSettingsPageSelector = createSelector(
verifiedName,
mostRecentVerifiedName,
verifiedNameHistory,
verifiedNameEnabled: verifiedNameSettings?.verifiedNameEnabled,
}),
);

export const certPreferenceSelector = createSelector(
verifiedNameSettingsSelector,
valuesSelector,
formValuesSelector,
mostRecentApprovedVerifiedNameValueSelector,
saveStateSelector,
errorSelector,
(
verifiedNameSettings,
committedValues,
formValues,
mostRecentApprovedVerifiedNameValue,
Expand All @@ -291,7 +285,6 @@ export const certPreferenceSelector = createSelector(
originalVerifiedName: mostRecentApprovedVerifiedNameValue?.verified_name || '',
useVerifiedNameForCerts: formValues.useVerifiedNameForCerts || false,
saveState,
verifiedNameEnabled: verifiedNameSettings.verifiedNameEnabled || false,
formErrors: errors,
}),
);
Expand Down
13 changes: 0 additions & 13 deletions src/account-settings/data/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,6 @@ export async function shouldDisplayDemographicsQuestions() {
return false;
}

export async function getVerifiedNameEnabled() {
let data;
const client = getAuthenticatedHttpClient();
try {
const requestUrl = `${getConfig().LMS_BASE_URL}/api/edx_name_affirmation/v1/verified_name_enabled`;
({ data } = await client.get(requestUrl));
} catch (error) {
return {};
}

return data;
}

export async function getVerifiedName() {
let data;
const client = getAuthenticatedHttpClient();
Expand Down
55 changes: 0 additions & 55 deletions src/id-verification/IdVerification.messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,21 +521,11 @@ const messages = defineMessages({
defaultMessage: 'The file you have selected is too large. Please try again with a file less than 10MB.',
description: 'Error message for file upload that is larger than 10MB.',
},
'id.verification.account.name.title': {
id: 'id.verification.account.name.title',
defaultMessage: 'Account Name Check',
description: 'Title for the Account Name Check page.',
},
'id.verification.name.check.title': {
id: 'id.verification.name.check.title',
defaultMessage: 'Double-Check Your Name',
description: 'Title for the page where a user double-checks that their name is correct.',
},
'id.verification.account.name.instructions': {
id: 'id.verification.account.name.instructions',
defaultMessage: 'The name on your account and the name on your ID must be an exact match. If not, please click "No" to update your account name.',
description: 'Text to verify that the account name matches the name on the ID photo.',
},
'id.verification.name.check.instructions': {
id: 'id.verification.name.check.instructions',
defaultMessage: 'Does the name below match the name on your government-issued ID? If not, update the name below to match your goverment-issued ID.',
Expand All @@ -546,41 +536,6 @@ const messages = defineMessages({
defaultMessage: 'If the name below does not match your government-issued ID, your identity verification will be denied.',
description: 'Text to inform the user that if the name displayed on the page does not match what is on their government-issued ID, identity verification will be denied.',
},
'id.verification.account.name.radio.label': {
id: 'id.verification.account.name.radio.label',
defaultMessage: 'Does the name on your ID match the Account Name below?',
description: 'Question to ask the user whether their account name match the name on their ID card.',
},
'id.verification.name.check.radio.label': {
id: 'id.verification.name.check.radio.label',
defaultMessage: 'Select an option',
description: 'Label for a radio button group where the user needs to choose one of two options.',
},
'id.verification.account.name.radio.yes': {
id: 'id.verification.account.name.radio.yes',
defaultMessage: 'Yes',
description: 'The radio button that says the account name matches.',
},
'id.verification.name.check.radio.yes': {
id: 'id.verification.name.check.radio.yes',
defaultMessage: 'Yes, the name below matches my ID',
description: 'Label for a radio button that indicates that the name displayed on the page matches the name on the user\'s ID.',
},
'id.verification.account.name.radio.no': {
id: 'id.verification.account.name.radio.no',
defaultMessage: 'No',
description: 'The radio button that says the account name does not match.',
},
'id.verification.name.check.radio.no': {
id: 'id.verification.name.check.radio.no',
defaultMessage: 'No, the name below does not match my ID',
description: 'Label for a radio button that indicates that the name displayed on the page does not match the name on the user\'s ID.',
},
'id.verification.account.name.error': {
id: 'id.verification.account.name.error',
defaultMessage: 'Please update account name to match the name on your ID.',
description: 'Error that shows when the user needs to update their account name to match the name on their ID.',
},
'id.verification.name.error': {
id: 'id.verification.name.error',
defaultMessage: 'Please enter your name as it appears on your government-issued ID.',
Expand All @@ -596,11 +551,6 @@ const messages = defineMessages({
defaultMessage: 'Account Settings',
description: 'Link to Account Settings.',
},
'id.verification.account.name.label': {
id: 'id.verification.account.name.label',
defaultMessage: 'Account Name',
description: 'Label for account name input.',
},
'id.verification.name.label': {
id: 'id.verification.name.label',
defaultMessage: 'Name',
Expand All @@ -611,11 +561,6 @@ const messages = defineMessages({
defaultMessage: 'Photo of your ID to be submitted.',
description: 'Alt text for the photo of the user\'s ID.',
},
'id.verification.account.name.save': {
id: 'id.verification.account.name.save',
defaultMessage: 'Save and Next',
description: 'Button to save the account name.',
},
'id.verification.review.title': {
id: 'id.verification.review.title',
defaultMessage: 'Review Your Photos',
Expand Down
16 changes: 1 addition & 15 deletions src/id-verification/IdVerificationContextProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { VerifiedNameContext } from './VerifiedNameContext';

export default function IdVerificationContextProvider({ children }) {
const { authenticatedUser } = useContext(AppContext);
const { verifiedNameHistoryCallStatus, verifiedName, verifiedNameEnabled } = useContext(VerifiedNameContext);
const { verifiedNameHistoryCallStatus, verifiedName } = useContext(VerifiedNameContext);

const idVerificationData = useAsyncCall(getExistingIdVerification);
const enrollmentsData = useAsyncCall(getEnrollments);
Expand Down Expand Up @@ -64,20 +64,6 @@ export default function IdVerificationContextProvider({ children }) {
existingIdVerification = idVerificationData.data;
}

if (verifiedNameHistoryCallStatus === SUCCESS_STATUS && idVerificationData.status === SUCCESS_STATUS) {
// With verified name we can redo verification multiple times
// if not a successful request prevents re-verification
if (!verifiedNameEnabled && existingIdVerification && !existingIdVerification.canVerify) {
const { status } = existingIdVerification;
canVerify = false;
if (status === 'pending' || status === 'approved') {
error = ERROR_REASONS.EXISTING_REQUEST;
} else {
error = ERROR_REASONS.CANNOT_VERIFY;
}
}
}

if (enrollmentsData.status === SUCCESS_STATUS && enrollmentsData?.data) {
const verifiedEnrollments = enrollmentsData.data.filter((enrollment) => (
VERIFIED_MODES.includes(enrollment.mode)
Expand Down
11 changes: 2 additions & 9 deletions src/id-verification/VerifiedNameContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,15 @@ export const VerifiedNameContext = createContext();
export function VerifiedNameContextProvider({ children }) {
const verifiedNameHistoryData = useAsyncCall(getVerifiedNameHistory);

let verifiedNameEnabled = false;
let verifiedName = '';
const { status, data } = verifiedNameHistoryData;
if (status === SUCCESS_STATUS && data) {
const { verified_name_enabled: verifiedNameFeatureEnabled, results } = data;
verifiedNameEnabled = verifiedNameFeatureEnabled;

if (verifiedNameFeatureEnabled) {
const applicableVerifiedName = getMostRecentApprovedOrPendingVerifiedName(results);
verifiedName = applicableVerifiedName;
}
const { results } = data;
verifiedName = getMostRecentApprovedOrPendingVerifiedName(results);
}

const value = {
verifiedNameHistoryCallStatus: status,
verifiedNameEnabled,
verifiedName,
};

Expand Down
Loading

0 comments on commit a18daec

Please sign in to comment.