mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 15:10:27 +00:00
Completed first-found updates for the user create / edit view.
This commit is contained in:
parent
9ac81363e3
commit
4a12d62828
@ -1,190 +1,205 @@
|
|||||||
{% 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
|
</div>
|
||||||
<small>{% if create %}New user{% else %}Edit user {{ user.username }}{% endif %}</small>
|
<div class="col-sm-6">
|
||||||
</h1>
|
<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('admin.manage_user') }}">Users</a></li>
|
||||||
|
<li class="breadcrumb-item active">{{ action_label }} User</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
|
||||||
<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('admin.manage_user') }}">Users</a></li>
|
|
||||||
<li class="breadcrumb-item active">{% if create %}Add user{% else %}Edit user "{{ user.username }}"{% endif %}</li>
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<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">
|
<input type="hidden" name="_csrf_token" value="{{ csrf_token() }}">
|
||||||
<h3 class="card-title">{% if create %}Add{% else %}Edit{% endif %} user</h3>
|
<input type="hidden" name="create" value="{{ create }}">
|
||||||
</div>
|
<div class="card card-outline card-primary shadow">
|
||||||
<form role="form" method="post"
|
<div class="card-header with-border">
|
||||||
action="{% if create %}{{ url_for('admin.edit_user') }}{% else %}{{ url_for('admin.edit_user', user_username=user.username) }}{% endif %}">
|
<h3 class="card-title">User Editor</h3>
|
||||||
<input type="hidden" name="_csrf_token" value="{{ csrf_token() }}">
|
</div>
|
||||||
<input type="hidden" name="create" value="{{ create }}">
|
<!-- /.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">×</button>
|
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">
|
||||||
<h4><i class="fa-solid fa-ban"></i> Error!</h4>
|
×
|
||||||
{{ error }}
|
</button>
|
||||||
|
<h4><i class="fa-solid fa-ban"></i> Error!</h4>
|
||||||
|
{{ error }}
|
||||||
|
</div>
|
||||||
|
<span class="help-block">{{ error }}</span>
|
||||||
|
{% endif %}
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<label class="control-label" for="firstname">First Name</label>
|
||||||
|
<input type="text" class="form-control" placeholder="First Name" name="firstname"
|
||||||
|
id="firstname"
|
||||||
|
{% if user %}value="{{ user.firstname }}" {% endif %}>
|
||||||
|
<span class="form-control-feedback"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<label class="control-label" for="lastname">Last Name</label>
|
||||||
|
<input type="text" class="form-control" placeholder="Last name" name="lastname"
|
||||||
|
id="lastname"
|
||||||
|
{% if user %}value="{{ user.lastname }}" {% endif %}>
|
||||||
|
<span class="form-control-feedback"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<label class="control-label" for="email">E-mail address</label>
|
||||||
|
<input type="email" class="form-control" placeholder="Email" name="email" id="email"
|
||||||
|
{% if user %}value="{{ user.email }}" {% endif %}>
|
||||||
|
<span class="form-control-feedback"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group has-feedback">
|
||||||
|
<label class="control-label" for="username">Username</label>
|
||||||
|
<input type="text" class="form-control" placeholder="Username" name="username"
|
||||||
|
id="username"
|
||||||
|
{% if user %}value="{{ user.username }}" {% endif %}
|
||||||
|
{% if not create %}disabled{% endif %}>
|
||||||
|
<span class="form-control-feedback"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group has-feedback {% if blank_password %}has-error{% endif %}">
|
||||||
|
<label class="control-label" for="password">Password</label>
|
||||||
|
<input type="password" class="form-control"
|
||||||
|
placeholder="Password {% if create %}(Required){% else %}(Leave blank to keep unchanged){% endif %}"
|
||||||
|
name="password" id="password">
|
||||||
|
<span class="form-control-feedback"></span>
|
||||||
|
{% if blank_password %}
|
||||||
|
<span class="help-block">The password cannot be blank.</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- /.card-body -->
|
||||||
|
<div class="card-footer">
|
||||||
|
<button type="submit" class="btn btn-primary" title="{{ action_label }} User">
|
||||||
|
{{ action_label }} User
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<!-- /.card-footer -->
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% if not create %}
|
||||||
|
{% if user.otp_secret %}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title">Two Factor Authentication</h3>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<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.
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer">
|
||||||
|
<button type="button" class="btn btn-warning button_otp_disable"
|
||||||
|
id="{{ user.username }}">
|
||||||
|
Disable Two Factor Authentication
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<span class="help-block">{{ error }}</span>
|
<!-- /.col -->
|
||||||
{% endif %}
|
|
||||||
<div class="form-group has-feedback">
|
<div class="col-12 col-sm-6 col-lg-8">
|
||||||
<label class="control-label" for="firstname">First Name</label>
|
<div class="card card-outline card-secondary shadow">
|
||||||
<input type="text" class="form-control" placeholder="First Name" name="firstname"
|
<div class="card-header">
|
||||||
{% if user %}value="{{ user.firstname }}" {% endif %}>
|
<h3 class="card-title">User Editor Help</h3>
|
||||||
<span class="form-control-feedback"></span>
|
</div>
|
||||||
</div>
|
<!-- /.card-header -->
|
||||||
<div class="form-group has-feedback">
|
<div class="card-body">
|
||||||
<label class="control-label" for="lastname">Last Name</label>
|
<p>Fill in all the fields to the in the form to the left.</p>
|
||||||
<input type="text" class="form-control" placeholder="Last name" name="lastname"
|
{% if create %}
|
||||||
{% if user %}value="{{ user.lastname }}" {% endif %}>
|
<p><strong>Newly created users do not have access to any domains.</strong> You will need
|
||||||
<span class="form-control-feedback"></span>
|
to grant
|
||||||
</div>
|
access to the user once it is created via the domain management buttons on the
|
||||||
<div class="form-group has-feedback">
|
dashboard.
|
||||||
<label class="control-label" for="email">E-mail address</label>
|
</p>
|
||||||
<input type="email" class="form-control" placeholder="Email" name="email" id="email"
|
{% else %}
|
||||||
{% if user %}value="{{ user.email }}" {% endif %}>
|
<p><strong>Username</strong> cannot be changed.</p>
|
||||||
<span class="form-control-feedback"></span>
|
<p><strong>Password</strong> can be left empty to keep the current password.</p>
|
||||||
</div>
|
{% endif %}
|
||||||
<p class="login-box-msg">Enter the account details below</p>
|
</div>
|
||||||
<div class="form-group has-feedback">
|
<!-- /.card-body -->
|
||||||
<label class="control-label" for="username">Username</label>
|
</div>
|
||||||
<input type="text" class="form-control" placeholder="Username" name="username"
|
<!-- /.card -->
|
||||||
{% if user %}value="{{ user.username }}" {% endif %}
|
</div>
|
||||||
{% if not create %}disabled{% endif %}>
|
<!-- /.col -->
|
||||||
<span class="form-control-feedback"></span>
|
|
||||||
</div>
|
|
||||||
<div class="form-group has-feedback {% if blank_password %}has-error{% endif %}">
|
|
||||||
<label class="control-label" for="username">Password</label>
|
|
||||||
<input type="password" class="form-control"
|
|
||||||
placeholder="Password {% if create %}(Required){% else %}(Leave blank to keep unchanged){% endif %}"
|
|
||||||
name="password">
|
|
||||||
<span class="form-control-feedback"></span>
|
|
||||||
{% if blank_password %}
|
|
||||||
<span class="help-block">The password cannot be blank.</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<!-- /.row -->
|
||||||
<button type="submit" class="btn btn-primary">
|
|
||||||
{% if create %}Create{% else %}Update{% endif %} User
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
{% if not create %}
|
<!-- /.container-fluid -->
|
||||||
{% if user.otp_secret %}
|
</section>
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h3 class="card-title">Two Factor Authentication</h3>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<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.
|
|
||||||
</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>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
<button type="button" class="btn btn-warning button_otp_disable" id="{{ user.username }}">
|
|
||||||
Disable Two Factor Authentication
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div class="col-8">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h3 class="card-title">
|
|
||||||
Help with {% if create %}creating a new{% else%}editing a{% endif %} user
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p>Fill in all the fields to the in the form to the left.</p>
|
|
||||||
{% if create %}
|
|
||||||
<p><strong>Newly created users do not have access to any domains.</strong> You will need to grant
|
|
||||||
access to the user once it is created via the domain management buttons on the dashboard.
|
|
||||||
</p>
|
|
||||||
{% else %}
|
|
||||||
<p><strong>Username</strong> cannot be changed.</p>
|
|
||||||
<p><strong>Password</strong> can be left empty to keep the current password.</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</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');
|
||||||
var info = "Are you sure you want to disable two factor authentication for user " + username + "?";
|
var info = "Are you sure you want to disable two factor authentication for user " + username + "?";
|
||||||
modal.find('.modal-body p').text(info);
|
modal.find('.modal-body p').text(info);
|
||||||
modal.find('#button_otp_disable_confirm').click(function () {
|
modal.find('#button_otp_disable_confirm').click(function () {
|
||||||
var postdata = {
|
var postdata = {
|
||||||
'action': 'user_otp_disable',
|
'action': 'user_otp_disable',
|
||||||
'data': username,
|
'data': username,
|
||||||
'_csrf_token': '{{ csrf_token() }}'
|
'_csrf_token': '{{ csrf_token() }}'
|
||||||
}
|
}
|
||||||
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-user', false, true);
|
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-user', false, true);
|
||||||
})
|
})
|
||||||
modal.modal('show');
|
modal.modal('show');
|
||||||
});
|
});
|
||||||
</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">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h4 class="modal-title">Confirmation</h4>
|
<h4 class="modal-title">Confirmation</h4>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p></p>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">
|
<button type="button" class="btn btn-default" data-dismiss="modal">
|
||||||
Close
|
Close
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-danger float-right" id="button_otp_disable_confirm">
|
<button type="button" class="btn btn-danger float-right" id="button_otp_disable_confirm">
|
||||||
Disable Two Factor Authentication
|
Disable Two Factor Authentication
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user