wisski-cloud-distillery/internal/dis/component/server/admin/html/instance_users.html
2023-12-01 23:37:25 +01:00

219 lines
No EOL
8.8 KiB
HTML

{{ $csrf := .CSRF }}
{{ $slug := .Instance.Slug }}
<div class="pure-u-1">
<h2 id="users">Users</h2>
<p>
This page provides a list of users found in this Drupal instance.
You can click the login button to authenticate as that user.
<br />
Please be aware that these never end an already existing session.
When already logged into drupal, an error message <em>Access denied</em> may appear.
To prevent this, log out of the drupal instance before clicking the button.
</p>
</div>
<div class="pure-u-1">
<div class="padding">
<div class="overflow">
<table class="pure-table pure-table-bordered">
<thead>
<tr>
<th>
ID
</th>
<th>
Active
</th>
<th>
Name
</th>
<th>
Email
</th>
<th>
Roles
</th>
<th>
Created
</th>
<th>
Last Login
</th>
<th>
Action
</th>
</tr>
</thead>
<tbody>
{{ $slug := .Instance.Slug }}
{{ $csrf := .CSRF }}
{{ range $index, $user := .Users }}
<tr {{ if not $user.Status }}class="disabled" aria-disabled="true"{{ end }}>
<td>
<code>{{ $user.UID }}</code>
</td>
<td>
<code>{{ $user.Status }}</code>
</td>
<td>
<code>{{ $user.Name }}</code>
</td>
<td>
{{ if $user.Mail }}
<a href="mailto:{{ $user.Mail }}">{{ $user.Mail }}</a>
{{ end }}
</td>
<td>
{{ range $role, $unuused := $user.Roles }}
<code>
{{ $role }}
</code>
{{ end }}
</td>
<td>
<code class="date">{{ $user.Created.Time.Format "2006-01-02T15:04:05Z07:00" }}</code>
</td>
<td>
<code class="date">{{ $user.Login.Time.Format "2006-01-02T15:04:05Z07:00" }}</code>
</td>
<td>
<form action="/admin/login" method="POST" target="_blank">
<input type="hidden" name="slug" value="{{ $slug }}">
<input type="hidden" name="user" value="{{ $user.Name }}">
<input type="submit" class="pure-button pure-button-action" value="Login in new window">
{{ $csrf }}
</form>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</div>
</div>
<div class="pure-u-1">
<h2 id="overview">Grants</h2>
<p>
A grant provides access for a specific distillery user to a specific WissKI instance.
Only <em>Distillery Administrators</em> can manage grants.
</p>
<ul>
<li>
<em>Distillery Users</em> must exist in order to grant them access to a specific instance
</li>
<li>
<em>Drupal Users</em> will be automatically created if they do not exist.
</li>
<li>
If <em>Admin</em> is checked and a user logs in, they will automatically be given the admin role.
For security reasons, an admin role is never automatically removed.
</li>
</ul>
{{ block "form/message" . }}
{{ $E := .Error }}
{{ if not (eq $E "") }}
<div class="pure-form-group">
<p class="error-message">
{{ $E }}
</p>
</div>
{{ end }}
{{ end }}
</div>
<div class="pure-u-1">
<div class="padding">
<div class="overflow">
<table class="pure-table pure-table-bordered pure-form">
<thead>
<tr>
<th>
Distillery Username
</th>
<th>
Drupal Username
</th>
<th>
Roles
</th>
<th>
Actions
</th>
</tr>
</thead>
<tbody>
{{ range $id, $grant := .Grants }}
<tr>
<td>
{{ $grant.User }}
<input type="hidden" name="distillery-user" value="{{ $grant.User }}" form="update-{{ $id }}">
<input type="hidden" name="distillery-user" value="{{ $grant.User }}" form="delete-{{ $id }}">
</td>
<td>
<input type="text" name="drupal-user" list="drupal-users" value="{{ $grant.DrupalUsername }}" form="update-{{ $id }}">
</td>
<td>
<label for="update={{ $id }}-admin">Admin</label>
<input type="checkbox" name="admin" id="update-{{ $id }}-admin" {{ if $grant.DrupalAdminRole }}checked{{end}} form="update-{{ $id }}">
</td>
<td>
<div class="pure-button-group" role="group">
<form id="update-{{ $id }}" method="POST" action="/admin/grants/" class="pure-form-group" autocomplete="off">
{{ $csrf }}
<input type="hidden" name="slug" value="{{ $slug }}">
<input type="hidden" name="action" value="update">
<input type="submit" class="pure-button" value="Update">
</form>
<form id="delete-{{ $id }}" method="POST" action="/admin/grants/" class="pure-form-group" autocomplete="off">
{{ $csrf }}
<input type="hidden" name="action" value="delete">
<input type="hidden" name="slug" value="{{ $slug }}">
<input type="submit" class="pure-button pure-button-danger" value="Delete">
</form>
</div>
</td>
</tr>
{{ end }}
<tr>
<td>
<input type="text" name="distillery-user" list="distillery-users" placeholder="Distillery User" form="add-grant">
</td>
<td>
<input type="text" name="drupal-user" list="drupal-users" placeholder="Drupal User" form="add-grant">
</td>
<td>
<label form="add-grant-admin">Admin</label>
<input type="checkbox" name="admin" id="add-grant-admin" form="add-grant">
</td>
<td>
<form id="add-grant" method="POST" action="/admin/grants/" class="pure-form-group">
{{ $csrf }}
<input type="hidden" name="action" value="update">
<input type="hidden" name="slug" value="{{ $slug }}">
<input type="submit" class="pure-button" value="Add New">
</form>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<datalist id="distillery-users">
{{ range $unused, $user := .Usernames }}
<option value="{{ $user }}">
{{ end }}
</datalist>
<datalist id="drupal-users">
{{ range $unused, $user := .Users }}
<option value="{{ $user.Name }}">
{{ end }}
</datalist>