Initial code for password change in python flask

This commit is contained in:
2025-07-16 14:13:26 +01:00
commit a6cc1b40ee
14 changed files with 1210 additions and 0 deletions

View File

@@ -0,0 +1,103 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Change account password - SME Server</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<div class="container">
<h1>Change account password</h1>
<div class="instructions">
<p>To change your account password, please fill out the following form. You will need to provide the name of your account, your old password, and your desired new password. (You must type the new password twice.)</p>
<p>If you cannot change your password because you have forgotten the old one, your local system administrator can reset your password using the <em>server manager</em>.</p>
</div>
<!-- Flash messages -->
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<div class="messages">
{% for category, message in messages %}
<div class="message {{ category }}">{{ message }}</div>
{% endfor %}
</div>
{% endif %}
{% endwith %}
<form method="POST" class="password-form">
<div class="form-container">
<table class="form-table">
<tr>
<td class="label-cell">Your account:</td>
<td class="input-cell">
<input type="text" name="username" id="username"
value="{{ request.form.username if request.form.username else '' }}"
required>
</td>
</tr>
<tr>
<td class="label-cell">Old password:</td>
<td class="input-cell">
<input type="password" name="old_password" id="old_password" required>
</td>
</tr>
<tr>
<td class="label-cell">New password:</td>
<td class="input-cell">
<input type="password" name="new_password" id="new_password" required>
</td>
</tr>
<tr>
<td class="label-cell">New password (verify):</td>
<td class="input-cell">
<input type="password" name="verify_password" id="verify_password" required>
</td>
</tr>
</table>
<div class="button-container">
<input type="submit" value="Change Password" class="submit-button">
</div>
</div>
</form>
<div class="footer">
<p>{{ version if version else 'SME Server 11 (beta1)' }}</p>
<p>{{ copyright_info.mitel if copyright_info else 'Copyright 1999-2006 Mitel Corporation' }}</p>
<p>{{ copyright_info.rights if copyright_info else 'All rights reserved.' }}</p>
<p>{{ copyright_info.koozali if copyright_info else 'Copyright (C) 2013 - 2021 Koozali Foundation Inc.' }}</p>
</div>
</div>
<script>
// Simple client-side validation
document.querySelector('.password-form').addEventListener('submit', function(e) {
const newPassword = document.getElementById('new_password').value;
const verifyPassword = document.getElementById('verify_password').value;
if (newPassword !== verifyPassword) {
e.preventDefault();
alert('New password and verification do not match');
return false;
}
if (newPassword.length < 8) {
e.preventDefault();
alert('Password must be at least 8 characters long');
return false;
}
});
// Clear password fields on page load for security
window.addEventListener('load', function() {
document.getElementById('old_password').value = '';
document.getElementById('new_password').value = '';
document.getElementById('verify_password').value = '';
});
</script>
</body>
</html>