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);
|
IdentityResult passwordChangeResult = await _userManager.ResetPasswordAsync(user, resetToken, model.NewPassword);
|
||||||
if (passwordChangeResult.Succeeded == true)
|
if (passwordChangeResult.Succeeded == true)
|
||||||
{
|
{
|
||||||
return Ok();
|
return Ok(passwordChangeResult);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -63,7 +63,11 @@ namespace gaseous_server.Controllers
|
|||||||
|
|
||||||
Config.SetSetting("FirstRunStatus", "1");
|
Config.SetSetting("FirstRunStatus", "1");
|
||||||
|
|
||||||
return Ok();
|
return Ok(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,6 +27,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" id="settings_users_edit_label"></td>
|
<td colspan="2" id="settings_users_edit_label"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" id="settings_users_edit_errorlabel" style="color: red;"></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -339,6 +342,7 @@
|
|||||||
var newPassword = document.getElementById('settings_users_edit_password').value;
|
var newPassword = document.getElementById('settings_users_edit_password').value;
|
||||||
|
|
||||||
if (newPassword.length > 0) {
|
if (newPassword.length > 0) {
|
||||||
|
console.log("New password value is long enough to commit to database");
|
||||||
var model = {
|
var model = {
|
||||||
"newPassword": newPassword,
|
"newPassword": newPassword,
|
||||||
"confirmPassword": newPassword
|
"confirmPassword": newPassword
|
||||||
@@ -348,12 +352,10 @@
|
|||||||
'/api/v1.1/Account/Users/' + modalVariables + '/Password',
|
'/api/v1.1/Account/Users/' + modalVariables + '/Password',
|
||||||
'POST',
|
'POST',
|
||||||
function(result) {
|
function(result) {
|
||||||
console.log(JSON.stringify(result));
|
savePasswordsCallback(result);
|
||||||
savePropertiesCallback();
|
|
||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
console.log(JSON.stringify(error));
|
savePasswordsCallback(error);
|
||||||
savePropertiesCallback();
|
|
||||||
},
|
},
|
||||||
JSON.stringify(model)
|
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() {
|
function savePropertiesCallback() {
|
||||||
GetUsers();
|
GetUsers();
|
||||||
closeDialog();
|
closeDialog();
|
||||||
|
@@ -28,6 +28,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" id="settings_users_new_label"></td>
|
<td colspan="2" id="settings_users_new_label"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" id="settings_users_new_errors" style="color: red;"></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" style="text-align: right; padding-top: 10px;">
|
<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>
|
<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',
|
'/api/v1.1/Account/Users',
|
||||||
'POST',
|
'POST',
|
||||||
function(result) {
|
function(result) {
|
||||||
GetUsers();
|
createUserCallback(result);
|
||||||
closeSubDialog();
|
|
||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
GetUsers();
|
createUserCallback(result);
|
||||||
closeSubDialog();
|
|
||||||
},
|
},
|
||||||
JSON.stringify(model)
|
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>
|
</script>
|
@@ -20,6 +20,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" id="profile_passwordnotice"></td>
|
<td colspan="2" id="profile_passwordnotice"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" id="profile_passworderrors" style="color: red;"></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" style="text-align: right;">
|
<td colspan="2" style="text-align: right;">
|
||||||
<button id="profile_resetpassword" value="Reset Password" disabled="disabled" onclick="ResetPassword();">Reset Password</button>
|
<button id="profile_resetpassword" value="Reset Password" disabled="disabled" onclick="ResetPassword();">Reset Password</button>
|
||||||
@@ -106,9 +109,16 @@
|
|||||||
|
|
||||||
function ResetPasswordCallback(result) {
|
function ResetPasswordCallback(result) {
|
||||||
var errorLabel = document.getElementById('profile_passwordnotice');
|
var errorLabel = document.getElementById('profile_passwordnotice');
|
||||||
|
var errorBox = document.getElementById('profile_passworderrors');
|
||||||
|
errorBox.innerHTML = '';
|
||||||
|
|
||||||
if (result.succeeded == false) {
|
console.log(result);
|
||||||
errorLabel.innerHTML = result.errors.description;
|
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 {
|
} else {
|
||||||
document.getElementById('profile_oldpassword').value = '';
|
document.getElementById('profile_oldpassword').value = '';
|
||||||
document.getElementById('profile_newpassword').value = '';
|
document.getElementById('profile_newpassword').value = '';
|
||||||
|
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
<table style="width: 100%; margin-top: 20px;" cellpadding="5px">
|
<table style="width: 100%; margin-top: 20px;" cellpadding="5px">
|
||||||
<tr>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
@@ -80,6 +80,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" id="login_passwordnotice"> </td>
|
<td colspan="2" id="login_passwordnotice"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" id="login_passworderrors" style="color: red;"></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" style="padding-top: 20px;">
|
<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>
|
<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) {
|
function loginCallback(result) {
|
||||||
switch(result.status) {
|
var errorLabel = document.getElementById('login_passwordnotice');
|
||||||
case 200:
|
var errorBox = document.getElementById('login_passworderrors');
|
||||||
window.location.replace('/index.html');
|
errorBox.innerHTML = '';
|
||||||
break;
|
|
||||||
default:
|
console.log(result);
|
||||||
// login failed
|
if (result.succeeded == false) {
|
||||||
break;
|
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>
|
</script>
|
||||||
|
@@ -66,6 +66,9 @@
|
|||||||
<input type="checkbox" id="login_rememberme"> <label for="login_rememberme">Remember Me</label>
|
<input type="checkbox" id="login_rememberme"> <label for="login_rememberme">Remember Me</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" id="login_errorlabel" style="color: red;"></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" style="padding-top: 20px;">
|
<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>
|
<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;
|
break;
|
||||||
default:
|
default:
|
||||||
// login failed
|
// login failed
|
||||||
|
document.getElementById('login_errorlabel').innerHTML = 'Incorrect password';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user