Implement account creation; add base class FormData to validate forms
This commit is contained in:
parent
23127dd193
commit
48925f283f
13 changed files with 392 additions and 96 deletions
98
templates/account_create.html.twig
Normal file
98
templates/account_create.html.twig
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
{% extends "base.html.twig" %}
|
||||
|
||||
{% block title %}Create account{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Accounts</h2>
|
||||
|
||||
<p>
|
||||
<b>Actions:</b>
|
||||
<a href="/accounts">List accounts</a> |
|
||||
<span>Create account</span>
|
||||
</p>
|
||||
|
||||
<h3>Create new account</h3>
|
||||
|
||||
<form action="/accounts/new" method="POST">
|
||||
{{ include('includes/form_result_box.html.twig') }}
|
||||
|
||||
<div class="form_box">
|
||||
<h4>Username</h4>
|
||||
<p>
|
||||
This is the primary mail address of the account and the username to use for login.
|
||||
The domain is part of the username (e.g. "user@example.com").
|
||||
</p>
|
||||
<details>
|
||||
<summary>Show list of known domains</summary>
|
||||
<p>{{ domainList ? domainList | join(', ') : 'No domains exist yet.' }}</p>
|
||||
</details>
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="create_username">Username:</label></td>
|
||||
<td><input id="create_username" name="username" value="{{ formData['username'] | default('') }}"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="form_box">
|
||||
<h4>Password</h4>
|
||||
<p>The password will be hashed using the current default hash algorithm.</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="create_password">New password:</label></td>
|
||||
<td><input type="password" id="create_password" name="password" value="{{ formData['password'] | default('') }}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="create_password_repeat">Repeat password:</label></td>
|
||||
<td><input type="password" id="create_password_repeat" name="password_repeat" value="{{ formData['password_repeat'] | default('') }}"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="form_box">
|
||||
<h4>Account status</h4>
|
||||
<table>
|
||||
<tr>
|
||||
<td>New account status:</td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="is_active" {{ formData is not defined or formData['is_active'] | default() ? 'checked' : '' }}/>
|
||||
Active
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="form_box">
|
||||
<h4>Home directory</h4>
|
||||
<p><b>Note:</b> By default the home directory will be determined automatically from the username and domain. Only change this if you know what you're doing!</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Default home directory:</td>
|
||||
<td><span class="gray">/srv/vmail/</span><samp><domain.tld></samp>/<samp><local_part></samp></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="create_home_dir">Set custom home directory:</label></td>
|
||||
<td>
|
||||
<span class="gray">/srv/vmail/</span><input id="create_home_dir" name="home_dir" value="{{ formData['home_dir'] | default('') }}"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="form_box">
|
||||
<h4><label for="create_memo">Admin memo</label></h4>
|
||||
<p>This field is only readable by admins.</p>
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="create_memo">Admin memo:</label></td>
|
||||
<td><textarea id="create_memo" name="memo" style="min-width: 40em;">{{ formData['memo'] | default('') }}</textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button type="submit">Create account</button>
|
||||
<button type="reset">Reset form</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
@ -16,21 +16,11 @@
|
|||
<h3>Edit account data</h3>
|
||||
|
||||
<form action="/accounts/{{ id }}/edit" method="POST">
|
||||
{% if success is defined %}
|
||||
<div class="success_box">
|
||||
<h4>Success</h4>
|
||||
{{ success }}
|
||||
</div>
|
||||
{% elseif error is defined %}
|
||||
<div class="error_box">
|
||||
<h4>Error</h4>
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ include('includes/form_result_box.html.twig') }}
|
||||
|
||||
<input type="hidden" name="user_id" value="{{ id }}"/>
|
||||
|
||||
<div class="edit_box">
|
||||
<div class="form_box">
|
||||
<h4>Username</h4>
|
||||
<table>
|
||||
<tr>
|
||||
|
|
@ -60,7 +50,7 @@
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<div class="edit_box">
|
||||
<div class="form_box">
|
||||
<h4>Password</h4>
|
||||
<p>The new password will be hashed using the current default hash algorithm.</p>
|
||||
<table>
|
||||
|
|
@ -75,7 +65,7 @@
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<div class="edit_box">
|
||||
<div class="form_box">
|
||||
<h4>Account status</h4>
|
||||
<table>
|
||||
<tr>
|
||||
|
|
@ -99,7 +89,7 @@
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<div class="edit_box">
|
||||
<div class="form_box">
|
||||
<h4>Home directory</h4>
|
||||
<p><b>Important:</b> Changing the home directory here will <b>NOT</b> move any existing mail data, this needs to be done
|
||||
manually!</p>
|
||||
|
|
@ -117,7 +107,7 @@
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<div class="edit_box">
|
||||
<div class="form_box">
|
||||
<h4><label for="edit_memo">Admin memo</label></h4>
|
||||
<p>This field is only readable by admins.</p>
|
||||
<table>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
<p>
|
||||
<b>Actions:</b>
|
||||
<span>List accounts</span> |
|
||||
<a href="/accounts/new">Create account</a>
|
||||
</p>
|
||||
|
||||
|
|
|
|||
11
templates/includes/form_result_box.html.twig
Normal file
11
templates/includes/form_result_box.html.twig
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{% if success is defined %}
|
||||
<div class="success_box">
|
||||
<h4>Success</h4>
|
||||
{{ success | raw }}
|
||||
</div>
|
||||
{% elseif error is defined %}
|
||||
<div class="error_box">
|
||||
<h4>Error</h4>
|
||||
{{ error | raw }}
|
||||
</div>
|
||||
{% endif %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue