Mar 04 2026: fixed enable/disable button
This commit is contained in:
@@ -5,20 +5,46 @@
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-8 offset-md-2">
|
||||
|
||||
{# ── Account Status card (edit mode only, not own account) ── #}
|
||||
{% if user and user.id != current_user.id %}
|
||||
<div class="card shadow-sm mb-3">
|
||||
<div class="card-body d-flex align-items-center justify-content-between">
|
||||
<div>
|
||||
<span class="fw-semibold me-2">Account Status:</span>
|
||||
<span class="badge fs-6 bg-{{ 'success' if user.active else 'secondary' }}">
|
||||
{{ 'Active' if user.active else 'Disabled' }}
|
||||
</span>
|
||||
<div class="form-text mt-1">
|
||||
{% if user.active %}
|
||||
Disabling this account will immediately prevent the user from logging in.
|
||||
{% else %}
|
||||
This account is currently disabled — the user cannot log in.
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<form method="POST" action="{{ url_for('auth.toggle_active', user_id=user.id) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit"
|
||||
class="btn btn-sm {{ 'btn-outline-secondary' if user.active else 'btn-outline-success' }}"
|
||||
onclick="return confirm('{{ 'Disable' if user.active else 'Enable' }} user {{ user.username }}?')">
|
||||
<i class="bi bi-{{ 'person-slash' if user.active else 'person-check' }} me-1"></i>
|
||||
{{ 'Disable Account' if user.active else 'Enable Account' }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# ── Edit form ── #}
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h4 class="mb-0">{{ title }}</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if user and not user.active %}
|
||||
<div class="alert alert-warning d-flex align-items-center gap-2 mb-4">
|
||||
<i class="bi bi-person-slash fs-5 flex-shrink-0"></i>
|
||||
<span>This account is currently <strong>disabled</strong>. The user cannot log in.</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
<form method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
{{ form.username.label(class="form-label") }}
|
||||
@@ -29,7 +55,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
{{ form.email.label(class="form-label") }}
|
||||
{{ form.email(class="form-control") }}
|
||||
@@ -40,7 +66,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
{{ form.password.label(class="form-label") }}
|
||||
@@ -51,7 +77,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-6 mb-3">
|
||||
{{ form.confirm_password.label(class="form-label") }}
|
||||
{{ form.confirm_password(class="form-control") }}
|
||||
@@ -62,38 +88,11 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb-4">
|
||||
{{ form.role.label(class="form-label") }}
|
||||
{{ form.role(class="form-select") }}
|
||||
</div>
|
||||
|
||||
{% if user and user.id != current_user.id %}
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-semibold">Account Status</label>
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<span class="badge fs-6 bg-{{ 'success' if user.active else 'secondary' }}">
|
||||
{{ 'Active' if user.active else 'Disabled' }}
|
||||
</span>
|
||||
<form method="POST" action="{{ url_for('auth.toggle_active', user_id=user.id) }}" class="d-inline">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit"
|
||||
class="btn btn-sm {{ 'btn-outline-secondary' if user.active else 'btn-outline-success' }}"
|
||||
onclick="return confirm('{{ 'Disable' if user.active else 'Enable' }} user {{ user.username }}?')">
|
||||
<i class="bi bi-{{ 'person-slash' if user.active else 'person-check' }} me-1"></i>
|
||||
{{ 'Disable Account' if user.active else 'Enable Account' }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="form-text">
|
||||
{% if user.active %}
|
||||
Disabling this account will immediately prevent the user from logging in.
|
||||
{% else %}
|
||||
Enabling this account will restore the user's ability to log in.
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
|
||||
Reference in New Issue
Block a user