Improved handling of password user feedback (#212)
This commit is contained in:
@@ -375,7 +375,7 @@ namespace gaseous_server.Controllers
|
||||
IdentityResult passwordChangeResult = await _userManager.ResetPasswordAsync(user, resetToken, model.NewPassword);
|
||||
if (passwordChangeResult.Succeeded == true)
|
||||
{
|
||||
return Ok();
|
||||
return Ok(passwordChangeResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -63,7 +63,11 @@ namespace gaseous_server.Controllers
|
||||
|
||||
Config.SetSetting("FirstRunStatus", "1");
|
||||
|
||||
return Ok();
|
||||
return Ok(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,9 @@
|
||||
<tr>
|
||||
<td colspan="2" id="settings_users_edit_label"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" id="settings_users_edit_errorlabel" style="color: red;"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -339,6 +342,7 @@
|
||||
var newPassword = document.getElementById('settings_users_edit_password').value;
|
||||
|
||||
if (newPassword.length > 0) {
|
||||
console.log("New password value is long enough to commit to database");
|
||||
var model = {
|
||||
"newPassword": newPassword,
|
||||
"confirmPassword": newPassword
|
||||
@@ -348,12 +352,10 @@
|
||||
'/api/v1.1/Account/Users/' + modalVariables + '/Password',
|
||||
'POST',
|
||||
function(result) {
|
||||
console.log(JSON.stringify(result));
|
||||
savePropertiesCallback();
|
||||
savePasswordsCallback(result);
|
||||
},
|
||||
function(error) {
|
||||
console.log(JSON.stringify(error));
|
||||
savePropertiesCallback();
|
||||
savePasswordsCallback(error);
|
||||
},
|
||||
JSON.stringify(model)
|
||||
);
|
||||
@@ -366,6 +368,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
function savePasswordsCallback(result) {
|
||||
console.log(result);
|
||||
if (result.succeeded == true) {
|
||||
savePropertiesCallback();
|
||||
} else {
|
||||
var errorBox = document.getElementById('settings_users_edit_errorlabel');
|
||||
errorBox.innerHTML = '';
|
||||
for (var i = 0; i < result.errors.length; i++) {
|
||||
var errorMessage = document.createElement('p');
|
||||
errorMessage.innerHTML = result.errors[i].description;
|
||||
errorBox.appendChild(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function savePropertiesCallback() {
|
||||
GetUsers();
|
||||
closeDialog();
|
||||
|
@@ -28,6 +28,9 @@
|
||||
<tr>
|
||||
<td colspan="2" id="settings_users_new_label"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" id="settings_users_new_errors" style="color: red;"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: right; padding-top: 10px;">
|
||||
<button value="OK" id="settings_users_new_okbutton" disabled="disabled" onclick="createUser();">OK</button><button value="Cancel" onclick="closeSubDialog();">Cancel</button>
|
||||
@@ -75,14 +78,27 @@
|
||||
'/api/v1.1/Account/Users',
|
||||
'POST',
|
||||
function(result) {
|
||||
GetUsers();
|
||||
closeSubDialog();
|
||||
createUserCallback(result);
|
||||
},
|
||||
function(error) {
|
||||
GetUsers();
|
||||
closeSubDialog();
|
||||
createUserCallback(result);
|
||||
},
|
||||
JSON.stringify(model)
|
||||
);
|
||||
}
|
||||
|
||||
function createUserCallback(result) {
|
||||
if (result.succeeded == true) {
|
||||
GetUsers();
|
||||
closeSubDialog();
|
||||
} else {
|
||||
var errorBox = document.getElementById('settings_users_new_errors');
|
||||
errorBox.innerHTML = '';
|
||||
for (var i = 0; i < result.errors.length; i++) {
|
||||
var errorMessage = document.createElement('p');
|
||||
errorMessage.innerHTML = result.errors[i].description;
|
||||
errorBox.appendChild(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@@ -20,6 +20,9 @@
|
||||
<tr>
|
||||
<td colspan="2" id="profile_passwordnotice"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" id="profile_passworderrors" style="color: red;"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: right;">
|
||||
<button id="profile_resetpassword" value="Reset Password" disabled="disabled" onclick="ResetPassword();">Reset Password</button>
|
||||
@@ -106,9 +109,16 @@
|
||||
|
||||
function ResetPasswordCallback(result) {
|
||||
var errorLabel = document.getElementById('profile_passwordnotice');
|
||||
var errorBox = document.getElementById('profile_passworderrors');
|
||||
errorBox.innerHTML = '';
|
||||
|
||||
if (result.succeeded == false) {
|
||||
errorLabel.innerHTML = result.errors.description;
|
||||
console.log(result);
|
||||
if (result.responseJSON.succeeded == false) {
|
||||
for (var i = 0; i < result.responseJSON.errors.length; i++) {
|
||||
var errorMessage = document.createElement('p');
|
||||
errorMessage.innerHTML = result.responseJSON.errors[i].description;
|
||||
errorBox.appendChild(errorMessage);
|
||||
}
|
||||
} else {
|
||||
document.getElementById('profile_oldpassword').value = '';
|
||||
document.getElementById('profile_newpassword').value = '';
|
||||
|
@@ -63,7 +63,7 @@
|
||||
|
||||
<table style="width: 100%; margin-top: 20px;" cellpadding="5px">
|
||||
<tr>
|
||||
<td colspan="2" style="font-size: 18px;">Create your account.</td>
|
||||
<td colspan="2" style="font-size: 18px;">Create your administrator account.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Email</th>
|
||||
@@ -80,6 +80,9 @@
|
||||
<tr>
|
||||
<td colspan="2" id="login_passwordnotice"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" id="login_passworderrors" style="color: red;"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="padding-top: 20px;">
|
||||
<button id="login_createaccount" type="button" value="Create Account" onclick="registerAccount();" disabled="disabled" style="margin-top: 10px; width: 100%; font-size: 16px; border-radius: 10px; padding-top: 10px; padding-bottom: 10px;">Create Account</button>
|
||||
@@ -154,13 +157,19 @@
|
||||
}
|
||||
|
||||
function loginCallback(result) {
|
||||
switch(result.status) {
|
||||
case 200:
|
||||
window.location.replace('/index.html');
|
||||
break;
|
||||
default:
|
||||
// login failed
|
||||
break;
|
||||
var errorLabel = document.getElementById('login_passwordnotice');
|
||||
var errorBox = document.getElementById('login_passworderrors');
|
||||
errorBox.innerHTML = '';
|
||||
|
||||
console.log(result);
|
||||
if (result.succeeded == false) {
|
||||
for (var i = 0; i < result.errors.length; i++) {
|
||||
var errorMessage = document.createElement('p');
|
||||
errorMessage.innerHTML = result.errors[i].description;
|
||||
errorBox.appendChild(errorMessage);
|
||||
}
|
||||
} else {
|
||||
window.location.replace('/index.html');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@@ -66,6 +66,9 @@
|
||||
<input type="checkbox" id="login_rememberme"> <label for="login_rememberme">Remember Me</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" id="login_errorlabel" style="color: red;"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="padding-top: 20px;">
|
||||
<button type="button" value="Sign In" onclick="UserLogin();" style="margin-top: 10px; width: 100%; font-size: 16px; border-radius: 10px; padding-top: 10px; padding-bottom: 10px;">Sign In</button>
|
||||
@@ -120,6 +123,7 @@
|
||||
break;
|
||||
default:
|
||||
// login failed
|
||||
document.getElementById('login_errorlabel').innerHTML = 'Incorrect password';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user