mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
Finished #49
This commit is contained in:
parent
2d016315c7
commit
24781fbd1f
11 changed files with 166 additions and 31 deletions
|
@ -49,7 +49,7 @@ namespace PlexRequests.UI.Modules
|
|||
model.Errored = Request.Query.error.HasValue;
|
||||
var adminCreated = UserMapper.DoUsersExist();
|
||||
model.AdminExists = adminCreated;
|
||||
return View["Login/Index", model];
|
||||
return View["Index", model];
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -82,7 +82,7 @@ namespace PlexRequests.UI.Modules
|
|||
dynamic model = new ExpandoObject();
|
||||
model.Errored = Request.Query.error.HasValue;
|
||||
|
||||
return View["Login/Register", model];
|
||||
return View["Register", model];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -109,7 +109,7 @@ namespace PlexRequests.UI.Modules
|
|||
return View["ChangePassword"];
|
||||
}
|
||||
|
||||
private Negotiator ChangePasswordPost()
|
||||
private Response ChangePasswordPost()
|
||||
{
|
||||
var username = Context.CurrentUser.UserName;
|
||||
var oldPass = Request.Form.OldPassword;
|
||||
|
@ -117,11 +117,16 @@ namespace PlexRequests.UI.Modules
|
|||
var newPasswordAgain = Request.Form.NewPasswordAgain;
|
||||
if (!newPassword.Equals(newPasswordAgain))
|
||||
{
|
||||
|
||||
return Response.AsJson(new JsonResponseModel { Message = "The passwords do not match", Result = false });
|
||||
}
|
||||
|
||||
var result = UserMapper.UpdateUser(username, oldPass, newPassword);
|
||||
return View["ChangePassword"];
|
||||
var result = UserMapper.UpdatePassword(username, oldPass, newPassword);
|
||||
if (result)
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Message = "Password has been changed!", Result = true });
|
||||
}
|
||||
|
||||
return Response.AsJson(new JsonResponseModel { Message = "Could not update the password in the database", Result = false });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,37 @@
|
|||
<form method="POST">
|
||||
<form method="POST" id="mainForm">
|
||||
<br />
|
||||
Old Password <input class="form-control" name="OldPassword" type="password" />
|
||||
New Password <input class="form-control" name="NewPassword" type="password" />
|
||||
New Password again <input class="form-control" name="NewPasswordAgain" type="password" />
|
||||
<br />
|
||||
<br />
|
||||
<input class="btn btn-success-outline" type="submit" value="Change Password" />
|
||||
<input class="btn btn-success-outline" id="save" type="submit" value="Change Password" />
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
$('#save').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $form = $("#mainForm");
|
||||
$.ajax({
|
||||
type: $form.prop("method"),
|
||||
data: $form.serialize(),
|
||||
url: $form.prop("action"),
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
if (response.result === true) {
|
||||
generateNotify(response.message, "success");
|
||||
} else {
|
||||
generateNotify(response.message, "warning");
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
generateNotify("Something went wrong!", "danger");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -72,9 +72,9 @@
|
|||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Admin <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="/admin">Settings</a></li>
|
||||
<li><a href="#">User Management</a></li>
|
||||
<li><a href="/changepassword">Change password</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#">Logout</a></li>
|
||||
<li><a href="/logout">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue