Completed first-found updates for the user create / edit view.

This commit is contained in:
Matt Scott 2023-02-20 09:22:41 -05:00
parent 9ac81363e3
commit 4a12d62828

View File

@ -1,28 +1,26 @@
{% extends "base.html" %} {% extends "base.html" %}
{% set active_page = "admin_users" %} {% set active_page = "admin_users" %}
{% if create %}
{% block title %} {% set action_label = 'Create' %}
<title> {% set form_action = url_for('admin.edit_user') %}
{% if create %}Add user{% else %}Edit user "{{ user.username }}"{% endif %} - {{ SITE_NAME }} {% else %}
</title> {% set action_label = 'Edit' %}
{% endblock %} {% set form_action = url_for('admin.edit_user', user_username=user.username) %}
{% endif %}
{% block title %}<title>{{ action_label }} User - {{ SITE_NAME }}</title>{% endblock %}
{% block dashboard_stat %} {% block dashboard_stat %}
<div class="content-header"> <div class="content-header">
<div class="container-fluid"> <div class="container-fluid">
<div class="row mb-2"> <div class="row mb-2">
<div class="col-sm-6"> <div class="col-sm-6">
<h1 class="m-0 text-dark"> <h1 class="m-0 text-dark">{{ action_label }} User</h1>
Users
<small>{% if create %}New user{% else %}Edit user {{ user.username }}{% endif %}</small>
</h1>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<ol class="breadcrumb float-sm-right"> <ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Dashboard</a></li> <li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Dashboard</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('admin.manage_user') }}">Users</a></li> <li class="breadcrumb-item"><a href="{{ url_for('admin.manage_user') }}">Users</a></li>
<li class="breadcrumb-item active">{% if create %}Add user{% else %}Edit user "{{ user.username }}"{% endif %}</li> <li class="breadcrumb-item active">{{ action_label }} User</li>
</ol> </ol>
</div> </div>
</div> </div>
@ -34,19 +32,21 @@
<section class="content"> <section class="content">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-4"> <div class="col-12 col-sm-6 col-lg-4">
<div class="card card-secondary"> <form role="form" method="post" action="{{ form_action }}">
<div class="card-header with-border">
<h3 class="card-title">{% if create %}Add{% else %}Edit{% endif %} user</h3>
</div>
<form role="form" method="post"
action="{% if create %}{{ url_for('admin.edit_user') }}{% else %}{{ url_for('admin.edit_user', user_username=user.username) }}{% endif %}">
<input type="hidden" name="_csrf_token" value="{{ csrf_token() }}"> <input type="hidden" name="_csrf_token" value="{{ csrf_token() }}">
<input type="hidden" name="create" value="{{ create }}"> <input type="hidden" name="create" value="{{ create }}">
<div class="card card-outline card-primary shadow">
<div class="card-header with-border">
<h3 class="card-title">User Editor</h3>
</div>
<!-- /.card-header -->
<div class="card-body"> <div class="card-body">
{% if error %} {% if error %}
<div class="alert alert-danger alert-dismissible"> <div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">
&times;
</button>
<h4><i class="fa-solid fa-ban"></i> Error!</h4> <h4><i class="fa-solid fa-ban"></i> Error!</h4>
{{ error }} {{ error }}
</div> </div>
@ -55,12 +55,14 @@
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<label class="control-label" for="firstname">First Name</label> <label class="control-label" for="firstname">First Name</label>
<input type="text" class="form-control" placeholder="First Name" name="firstname" <input type="text" class="form-control" placeholder="First Name" name="firstname"
id="firstname"
{% if user %}value="{{ user.firstname }}" {% endif %}> {% if user %}value="{{ user.firstname }}" {% endif %}>
<span class="form-control-feedback"></span> <span class="form-control-feedback"></span>
</div> </div>
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<label class="control-label" for="lastname">Last Name</label> <label class="control-label" for="lastname">Last Name</label>
<input type="text" class="form-control" placeholder="Last name" name="lastname" <input type="text" class="form-control" placeholder="Last name" name="lastname"
id="lastname"
{% if user %}value="{{ user.lastname }}" {% endif %}> {% if user %}value="{{ user.lastname }}" {% endif %}>
<span class="form-control-feedback"></span> <span class="form-control-feedback"></span>
</div> </div>
@ -70,32 +72,34 @@
{% if user %}value="{{ user.email }}" {% endif %}> {% if user %}value="{{ user.email }}" {% endif %}>
<span class="form-control-feedback"></span> <span class="form-control-feedback"></span>
</div> </div>
<p class="login-box-msg">Enter the account details below</p>
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<label class="control-label" for="username">Username</label> <label class="control-label" for="username">Username</label>
<input type="text" class="form-control" placeholder="Username" name="username" <input type="text" class="form-control" placeholder="Username" name="username"
id="username"
{% if user %}value="{{ user.username }}" {% endif %} {% if user %}value="{{ user.username }}" {% endif %}
{% if not create %}disabled{% endif %}> {% if not create %}disabled{% endif %}>
<span class="form-control-feedback"></span> <span class="form-control-feedback"></span>
</div> </div>
<div class="form-group has-feedback {% if blank_password %}has-error{% endif %}"> <div class="form-group has-feedback {% if blank_password %}has-error{% endif %}">
<label class="control-label" for="username">Password</label> <label class="control-label" for="password">Password</label>
<input type="password" class="form-control" <input type="password" class="form-control"
placeholder="Password {% if create %}(Required){% else %}(Leave blank to keep unchanged){% endif %}" placeholder="Password {% if create %}(Required){% else %}(Leave blank to keep unchanged){% endif %}"
name="password"> name="password" id="password">
<span class="form-control-feedback"></span> <span class="form-control-feedback"></span>
{% if blank_password %} {% if blank_password %}
<span class="help-block">The password cannot be blank.</span> <span class="help-block">The password cannot be blank.</span>
{% endif %} {% endif %}
</div> </div>
</div> </div>
<!-- /.card-body -->
<div class="card-footer"> <div class="card-footer">
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary" title="{{ action_label }} User">
{% if create %}Create{% else %}Update{% endif %} User {{ action_label }} User
</button> </button>
</div> </div>
</form> <!-- /.card-footer -->
</div> </div>
</form>
{% if not create %} {% if not create %}
{% if user.otp_secret %} {% if user.otp_secret %}
<div class="card"> <div class="card">
@ -103,14 +107,16 @@
<h3 class="card-title">Two Factor Authentication</h3> <h3 class="card-title">Two Factor Authentication</h3>
</div> </div>
<div class="card-body"> <div class="card-body">
<p>If two factor authentication is configured for this user and is causing problems due to a lost device or <p>If two-factor authentication is configured for this user and is causing problems
due to a lost device or
technical issue, it can be disabled here. technical issue, it can be disabled here.
</p> </p>
<p>The user will need to reconfigure two factor authentication, to re-enable it.</p> <p>The user will need to reconfigure two-factor authentication, to re-enable it.</p>
<p><strong>Beware: This could compromise security!</strong></p> <p><strong>Beware: This could compromise security!</strong></p>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<button type="button" class="btn btn-warning button_otp_disable" id="{{ user.username }}"> <button type="button" class="btn btn-warning button_otp_disable"
id="{{ user.username }}">
Disable Two Factor Authentication Disable Two Factor Authentication
</button> </button>
</div> </div>
@ -118,34 +124,42 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
<div class="col-8"> <!-- /.col -->
<div class="card">
<div class="col-12 col-sm-6 col-lg-8">
<div class="card card-outline card-secondary shadow">
<div class="card-header"> <div class="card-header">
<h3 class="card-title"> <h3 class="card-title">User Editor Help</h3>
Help with {% if create %}creating a new{% else%}editing a{% endif %} user
</h3>
</div> </div>
<!-- /.card-header -->
<div class="card-body"> <div class="card-body">
<p>Fill in all the fields to the in the form to the left.</p> <p>Fill in all the fields to the in the form to the left.</p>
{% if create %} {% if create %}
<p><strong>Newly created users do not have access to any domains.</strong> You will need to grant <p><strong>Newly created users do not have access to any domains.</strong> You will need
access to the user once it is created via the domain management buttons on the dashboard. to grant
access to the user once it is created via the domain management buttons on the
dashboard.
</p> </p>
{% else %} {% else %}
<p><strong>Username</strong> cannot be changed.</p> <p><strong>Username</strong> cannot be changed.</p>
<p><strong>Password</strong> can be left empty to keep the current password.</p> <p><strong>Password</strong> can be left empty to keep the current password.</p>
{% endif %} {% endif %}
</div> </div>
<!-- /.card-body -->
</div> </div>
<!-- /.card -->
</div> </div>
<!-- /.col -->
</div> </div>
<!-- /.row -->
</div> </div>
<!-- /.container-fluid -->
</section> </section>
{% endblock %} {% endblock %}
{% block extrascripts %} {% block extrascripts %}
<script> <script>
// handle disabling two factor authentication // handle disabling two-factor authentication
$(document.body).on('click', '.button_otp_disable', function () { $(document.body).on('click', '.button_otp_disable', function () {
var modal = $("#modal_otp_disable"); var modal = $("#modal_otp_disable");
var username = $(this).prop('id'); var username = $(this).prop('id');
@ -163,6 +177,7 @@
}); });
</script> </script>
{% endblock %} {% endblock %}
{% block modals %} {% block modals %}
<div class="modal fade modal-warning" id="modal_otp_disable"> <div class="modal fade modal-warning" id="modal_otp_disable">
<div class="modal-dialog"> <div class="modal-dialog">