Skip to content

Commit 842343a

Browse files
pungmeflovilmart
authored andcommitted
Add password confirmation to choose_password (parse-community#3994)
* update choose_password to have the confirmation * update commander * reverted the base * remove some spaces * nits * more nits
1 parent a33c08a commit 842343a

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

views/choose_password

+42-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@
108108
background-image: -ms-linear-gradient(#00395E,#005891);
109109
background-image: linear-gradient(#00395E,#005891);
110110
}
111-
111+
112+
button:disabled,
113+
button[disabled] {
114+
opacity: 0.5;
115+
}
116+
112117
input {
113118
color: black;
114119
cursor: auto;
@@ -126,6 +131,12 @@
126131
word-spacing: 0px;
127132
}
128133

134+
#password_match_info {
135+
margin-top: 0px;
136+
font-size: 13px;
137+
color: red;
138+
}
139+
129140
</style>
130141
</head>
131142
<body>
@@ -134,11 +145,20 @@
134145
<div class='error' id='error'></div>
135146
<form id='form' action='#' method='POST'>
136147
<label>New Password for <span id='username_label'></span></label>
137-
<input name="new_password" type="password" />
148+
149+
<span>New Password</span>
150+
<input name="new_password" type="password" id="password"/> <br>
151+
152+
<span>Confirm New Password</span>
153+
<input name="confirm_new_password" type="password" id="password_confirm"/>
154+
<span id="password_match_info"></span>
155+
138156
<input name='utf-8' type='hidden' value='✓' />
139157
<input name="username" id="username" type="hidden" />
140158
<input name="token" id="token" type="hidden" />
141-
<button>Change Password</button>
159+
160+
161+
<button id="change_password">Change Password</button>
142162
</form>
143163

144164
<script language='javascript' type='text/javascript'>
@@ -162,6 +182,9 @@
162182
document.getElementById('form').setAttribute('action', base + '/apps/' + id + '/request_password_reset');
163183
document.getElementById('username').value = urlParams['username'];
164184
document.getElementById('username_label').appendChild(document.createTextNode(urlParams['username']));
185+
document.getElementById("password").oninput = validatePassword;
186+
document.getElementById("password_confirm").oninput = validatePassword;
187+
document.getElementById("change_password").disabled = true;
165188

166189
document.getElementById('token').value = urlParams['token'];
167190
if (urlParams['error']) {
@@ -170,6 +193,22 @@
170193
if (urlParams['app']) {
171194
document.getElementById('app').appendChild(document.createTextNode(' for ' + urlParams['app']));
172195
}
196+
197+
function validatePassword() {
198+
var pass2 = document.getElementById("password").value;
199+
var pass1 = document.getElementById("password_confirm").value;
200+
if(pass1 !== pass2) {
201+
if(document.getElementById("password_confirm").value) {
202+
document.getElementById("change_password").disabled = true;
203+
document.getElementById("password_match_info").innerHTML = "Must match the previous entry";
204+
}
205+
} else {
206+
document.getElementById("change_password").disabled = false;
207+
document.getElementById("password_match_info").innerHTML = "";
208+
}
209+
//empty string means no validation error
210+
}
211+
173212
}
174213
//-->
175214
</script>

0 commit comments

Comments
 (0)