Add password change (#88)
This commit is contained in:
parent
27c1f78dbd
commit
62e80cec63
7 changed files with 98 additions and 2 deletions
|
|
@ -1002,6 +1002,16 @@ function showLoginFrame() {
|
|||
modal.modal("hide");
|
||||
}
|
||||
}
|
||||
else if(e.data.substring(0, e.data.indexOf(":")) == "cytube-changepass") {
|
||||
var data = e.data.substring(e.data.indexOf(":")+1);
|
||||
data = JSON.parse(data);
|
||||
if(data.error) {
|
||||
alert(data.error);
|
||||
}
|
||||
else if(data.success) {
|
||||
alert("Password changed");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(window.addEventListener) {
|
||||
window.addEventListener("message", respond, false);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,17 @@
|
|||
<meta charset="utf-8">
|
||||
<title>CyTube - Login</title>
|
||||
<link rel="stylesheet" href="assets/css/bootstrap.css">
|
||||
<style type="text/css">
|
||||
#username, #pw {
|
||||
width: 95%;
|
||||
}
|
||||
#login, #register {
|
||||
width: 49%;
|
||||
}
|
||||
#changepass {
|
||||
width: 99%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form class="form-horizontal" action="javascript:void(0)">
|
||||
|
|
@ -19,6 +30,12 @@
|
|||
<input type="password" id="pw">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" style="display: none" id="newpassdiv">
|
||||
<label class="control-label" for="newpass" id="nplabel">New Password</label>
|
||||
<div class="controls">
|
||||
<input type="password" id="newpass">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" style="display: none" id="pw2div">
|
||||
<label class="control-label" for="pw2" id="confirm">Confirm Password</label>
|
||||
<div class="controls">
|
||||
|
|
@ -31,6 +48,11 @@
|
|||
<button class="btn" id="register">Register</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button class="btn" id="changepass">Change Password</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="assets/js/jquery.js" type="text/javascript"></script>
|
||||
<script src="assets/js/iourl.js" type="text/javascript"></script>
|
||||
|
|
@ -65,6 +87,24 @@
|
|||
source.postMessage("cytube-login:"+JSON.stringify(data), document.location);
|
||||
});
|
||||
});
|
||||
$("#changepass").click(function() {
|
||||
if($("#newpassdiv").css("display") == "none") {
|
||||
$("#newpassdiv").css("display", "");
|
||||
$("#pw2div").css("display", "");
|
||||
return false;
|
||||
}
|
||||
else if($("#newpass").val() != $("#pw2").val()) {
|
||||
$("#confirm").addClass("text-error");
|
||||
return;
|
||||
}
|
||||
$.getJSON(IO_URL+"/api/json/changepass?name="+$("#username").val()+"&oldpw="+$("#pw").val()+"&newpw="+$("#newpass").val()+"&callback=?", function(data) {
|
||||
if(data.success) {
|
||||
$("#newpassdiv").css("display", "none");
|
||||
$("#pw2div").css("display", "none");
|
||||
}
|
||||
source.postMessage("cytube-changepass:"+JSON.stringify(data), document.location);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue