enforce password change if password is changeme

This commit is contained in:
2025-05-27 15:13:36 +02:00
parent 071b8ca2aa
commit 149487195b
12 changed files with 132 additions and 42 deletions

View File

@@ -0,0 +1,50 @@
{% extends "common/base.html" %}
{% block title %}Change Password{% endblock %}
{% block content %}
<div class="container mx-auto px-4 py-8">
<div class="max-w-md mx-auto">
<div class="bg-white rounded-lg shadow p-6">
<h2 class="text-2xl font-bold mb-6 text-center" style="color: var(--primary-color);">Change Password</h2>
<form method="POST" class="space-y-4">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div>
<label for="current_password" class="block text-sm font-medium text-gray-700 mb-1">
<i class="fas fa-key me-2" style="color: var(--primary-color);"></i>Current Password
</label>
<input type="password" name="current_password" id="current_password" required
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2"
style="--tw-ring-color: var(--primary-color);">
</div>
<div>
<label for="new_password" class="block text-sm font-medium text-gray-700 mb-1">
<i class="fas fa-lock me-2" style="color: var(--primary-color);"></i>New Password
</label>
<input type="password" name="new_password" id="new_password" required
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2"
style="--tw-ring-color: var(--primary-color);">
</div>
<div>
<label for="confirm_password" class="block text-sm font-medium text-gray-700 mb-1">
<i class="fas fa-check-circle me-2" style="color: var(--primary-color);"></i>Confirm New Password
</label>
<input type="password" name="confirm_password" id="confirm_password" required
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2"
style="--tw-ring-color: var(--primary-color);">
</div>
<button type="submit" class="w-full text-white px-6 py-2 rounded-lg transition duration-200"
style="background-color: var(--primary-color); border: 1px solid var(--primary-color);"
onmouseover="this.style.backgroundColor='var(--primary-light)'"
onmouseout="this.style.backgroundColor='var(--primary-color)'">
<i class="fas fa-save me-2"></i>Change Password
</button>
</form>
</div>
</div>
</div>
{% endblock %}

View File

@@ -6,7 +6,7 @@
<div class="d-flex justify-content-between align-items-center mb-6">
<div>
<h3 class="mb-0">
<i class="fas fa-user me-2" style="color:#16767b;"></i>
<i class="fas fa-user me-2" style="color: var(--primary-color);"></i>
{% if title %}
{{ title }}
{% else %}
@@ -71,36 +71,6 @@
{% endif %}
</div>
{% if current_user.is_admin %}
<div class="relative">
{{ form.new_password.label(class="block text-sm font-medium text-gray-700 mb-1") }}
{{ form.new_password(class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 pr-10", autocomplete="new-password", id="new_password") }}
<button type="button" tabindex="-1" class="absolute right-2 top-9 text-gray-500" style="background: none; border: none;" onmousedown="showPwd('new_password')" onmouseup="hidePwd('new_password')" onmouseleave="hidePwd('new_password')">
<i class="fas fa-eye"></i>
</button>
</div>
<div class="relative">
{{ form.confirm_password.label(class="block text-sm font-medium text-gray-700 mb-1") }}
{{ form.confirm_password(class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 pr-10", autocomplete="new-password", id="confirm_password") }}
<button type="button" tabindex="-1" class="absolute right-2 top-9 text-gray-500" style="background: none; border: none;" onmousedown="showPwd('confirm_password')" onmouseup="hidePwd('confirm_password')" onmouseleave="hidePwd('confirm_password')">
<i class="fas fa-eye"></i>
</button>
{% if form.confirm_password.errors %}
{% for error in form.confirm_password.errors %}
<p class="mt-1 text-sm text-red-600">{{ error }}</p>
{% endfor %}
{% endif %}
</div>
<script>
function showPwd(id) {
document.getElementById(id).type = 'text';
}
function hidePwd(id) {
document.getElementById(id).type = 'password';
}
</script>
{% endif %}
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
{{ form.phone.label(class="block text-sm font-medium text-gray-700 mb-1") }}
@@ -177,7 +147,10 @@
</div>
<div class="flex justify-end">
{{ form.submit(class="text-white px-6 py-2 rounded-lg transition duration-200", style="background-color: #16767b; border: 1px solid #16767b;", onmouseover="this.style.backgroundColor='#1a8a90'", onmouseout="this.style.backgroundColor='#16767b'") }}
{{ form.submit(class="text-white px-6 py-2 rounded-lg transition duration-200",
style="background-color: var(--primary-color); border: 1px solid var(--primary-color);",
onmouseover="this.style.backgroundColor='var(--primary-light)'",
onmouseout="this.style.backgroundColor='var(--primary-color)'") }}
</div>
</form>
</div>