You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The text user needs to type to confirm deletion
21
+
// TODO: This should be stored in a config file
22
+
this.confirmationText='DELETE_MY_ACCOUNT';
23
+
19
24
this.state={
20
-
password: '',
21
-
passwordSubmitted: false,
22
-
passwordValid: true,
25
+
confirmationInput: '',
26
+
confirmationSubmitted: false,
27
+
confirmationValid: true,
23
28
validationMessage: '',
24
29
validationErrorDetails: '',
25
30
accountQueuedForDeletion: false,
@@ -36,13 +41,13 @@ class StudentAccountDeletionConfirmationModal extends React.Component {
36
41
37
42
deleteAccount(){
38
43
returnthis.setState(
39
-
{passwordSubmitted: true},
44
+
{confirmationSubmitted: true},
40
45
()=>(
41
-
deactivate(this.state.password)
46
+
deactivate()
42
47
.then(()=>this.setState({
43
48
accountQueuedForDeletion: true,
44
49
responseError: false,
45
-
passwordSubmitted: false,
50
+
confirmationSubmitted: false,
46
51
validationMessage: '',
47
52
validationErrorDetails: '',
48
53
}))
@@ -52,41 +57,51 @@ class StudentAccountDeletionConfirmationModal extends React.Component {
52
57
}
53
58
54
59
failedSubmission(error){
55
-
consttitle=error.message==='403' ? gettext('Password is incorrect') : gettext('Unable to delete account');
56
-
constbody=error.message==='403' ? gettext('Please re-enter your password.') : gettext('Sorry, there was an error trying to process your request. Please try again later.');
60
+
consttitle=gettext('Unable to delete account');
61
+
constbody=gettext('Sorry, there was an error trying to process your request. Please try again later.');
57
62
58
63
this.setState({
59
-
passwordSubmitted: false,
64
+
confirmationSubmitted: false,
60
65
responseError: true,
61
-
passwordValid: false,
66
+
confirmationValid: false,
62
67
validationMessage: title,
63
68
validationErrorDetails: body,
64
69
});
65
70
}
66
71
67
-
handlePasswordInputChange(value){
68
-
this.setState({password: value});
72
+
handleConfirmationInputChange(value){
73
+
this.setState({confirmationInput: value});
74
+
this.confirmationFieldValidation(value);
69
75
}
70
76
71
-
passwordFieldValidation(value){
72
-
letfeedback={passwordValid: true};
77
+
confirmationFieldValidation(value){
78
+
letfeedback={confirmationValid: true};
73
79
74
80
if(value.length<1){
75
81
feedback={
76
-
passwordValid: false,
77
-
validationMessage: gettext('A Password is required'),
82
+
confirmationValid: false,
83
+
validationMessage: gettext('Confirmation text is required'),
78
84
validationErrorDetails: '',
79
85
};
86
+
}elseif(value!==this.confirmationText){
87
+
feedback={
88
+
confirmationValid: false,
89
+
validationMessage: gettext('Confirmation text does not match'),
90
+
validationErrorDetails: StringUtils.interpolate(
91
+
gettext('Please type "{confirmationText}" exactly as shown.'),
92
+
{confirmationText: this.confirmationText}
93
+
),
94
+
};
80
95
}
81
96
82
97
this.setState(feedback);
83
98
}
84
99
85
100
renderConfirmationModal(){
86
101
const{
87
-
passwordValid,
88
-
password,
89
-
passwordSubmitted,
102
+
confirmationValid,
103
+
confirmationInput,
104
+
confirmationSubmitted,
90
105
responseError,
91
106
validationErrorDetails,
92
107
validationMessage,
@@ -123,6 +138,10 @@ class StudentAccountDeletionConfirmationModal extends React.Component {
0 commit comments