mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-04-19 20:09:14 +03:00
Allow a user to change his own password. Closes #62
This commit is contained in:
parent
22dfbed83d
commit
4478f1eed3
2 changed files with 71 additions and 3 deletions
|
@ -53,6 +53,14 @@ input[type="submit"] {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
input[type="submit"]:disabled {
|
||||||
|
background: none repeat scroll 0 0 #FF0000;
|
||||||
|
border: medium none;
|
||||||
|
color: #FFFFFF;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
.label {
|
.label {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 0 10px 0 0;
|
margin: 0 10px 0 0;
|
||||||
|
|
60
index.php
60
index.php
|
@ -18,6 +18,16 @@ if (!is_logged_in() and isset($_POST['formname']) and $_POST['formname'] === "lo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_logged_in() and isset($_POST['formname']) and $_POST['formname'] === "changepwform") {
|
||||||
|
if (get_sess_user() == $_POST['username']) {
|
||||||
|
if (!update_user(get_sess_user(), is_adminuser(), $_POST['password'])) {
|
||||||
|
$errormsg = "Unable to update password!\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$errormsg = "You can only update your own password!".$_POST['username'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
@ -114,9 +124,14 @@ if ($blocklogin === TRUE) {
|
||||||
<?php if (is_adminuser()) { ?>
|
<?php if (is_adminuser()) { ?>
|
||||||
<li><a href="#" id="useradmin">Users</a></li>
|
<li><a href="#" id="useradmin">Users</a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<li><a href="#" id="aboutme">About me</a></li>
|
||||||
<li><a href="index.php?logout=1">Logout</a></li>
|
<li><a href="index.php?logout=1">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if (isset($errormsg)) {
|
||||||
|
echo '<span style="color: red">' . $errormsg . '</span><br />';
|
||||||
|
}
|
||||||
|
?>
|
||||||
<div id="zones">
|
<div id="zones">
|
||||||
<?php if (is_adminuser() or $allowzoneadd === TRUE) { ?>
|
<?php if (is_adminuser() or $allowzoneadd === TRUE) { ?>
|
||||||
<div style="visibility: hidden;" id="ImportZone"></div>
|
<div style="visibility: hidden;" id="ImportZone"></div>
|
||||||
|
@ -133,6 +148,34 @@ if ($blocklogin === TRUE) {
|
||||||
<div class="tables" id="Users"></div>
|
<div class="tables" id="Users"></div>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
<div id="AboutMe">
|
||||||
|
<div class="tables">
|
||||||
|
<p>Hi <?php echo get_sess_user(); ?>. You can change your password here.</p>
|
||||||
|
|
||||||
|
<form action="index.php" method="POST">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Username:</td>
|
||||||
|
<td><input readonly value="<?php echo get_sess_user(); ?>" id="username" type="text" name="username"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Password:</td>
|
||||||
|
<td><input type="password" name="password" id="changepw1"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="label">Password again:</td>
|
||||||
|
<td><input type="password" name="password2" id="changepw2"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td><input type="submit" name="submit" id="changepwsubmit" value="Change password!"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<input type="hidden" name="formname" value="changepwform">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.csrf_token = '<?php echo CSRF_TOKEN ?>';
|
window.csrf_token = '<?php echo CSRF_TOKEN ?>';
|
||||||
|
@ -714,6 +757,14 @@ $(document).ready(function () {
|
||||||
|
|
||||||
stimer = 0;
|
stimer = 0;
|
||||||
|
|
||||||
|
$('#changepw1, #changepw2').on('input', function(e) {
|
||||||
|
if ($('#changepw1').val() != $('#changepw2').val()) {
|
||||||
|
$('#changepwsubmit').prop("disabled",true);
|
||||||
|
} else {
|
||||||
|
$('#changepwsubmit').prop("disabled",false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#domsearch').on('input', function (e) {
|
$('#domsearch').on('input', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
clearTimeout(stimer);
|
clearTimeout(stimer);
|
||||||
|
@ -722,13 +773,22 @@ $(document).ready(function () {
|
||||||
|
|
||||||
<?php if (is_adminuser()) { ?>
|
<?php if (is_adminuser()) { ?>
|
||||||
$('#Users').hide();
|
$('#Users').hide();
|
||||||
|
$('#AboutMe').hide();
|
||||||
|
$('#aboutme').click(function () {
|
||||||
|
$('#Users').hide();
|
||||||
|
$('#MasterZones').hide();
|
||||||
|
$('#SlaveZones').hide();
|
||||||
|
$('#AboutMe').show();
|
||||||
|
});
|
||||||
$('#useradmin').click(function () {
|
$('#useradmin').click(function () {
|
||||||
$('#Users').show();
|
$('#Users').show();
|
||||||
$('#MasterZones').hide();
|
$('#MasterZones').hide();
|
||||||
$('#SlaveZones').hide();
|
$('#SlaveZones').hide();
|
||||||
|
$('#AboutMe').hide();
|
||||||
});
|
});
|
||||||
$('#zoneadmin').click(function () {
|
$('#zoneadmin').click(function () {
|
||||||
$('#Users').hide();
|
$('#Users').hide();
|
||||||
|
$('#AboutMe').hide();
|
||||||
$('#MasterZones').show();
|
$('#MasterZones').show();
|
||||||
$('#SlaveZones').show();
|
$('#SlaveZones').show();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue