2020-05-28 10:42:36 +02:00
|
|
|
<main class="container">
|
|
|
|
<div id="users-block" class="my-3 p-3 bg-white rounded shadow">
|
2020-09-19 22:19:55 +02:00
|
|
|
<h6 class="border-bottom pb-2 mb-3">Registered Users</h6>
|
2020-05-28 10:42:36 +02:00
|
|
|
|
2020-06-01 18:58:38 +02:00
|
|
|
<div class="table-responsive-xl small">
|
2020-09-19 22:19:55 +02:00
|
|
|
<table id="users-table" class="table table-sm table-striped table-hover">
|
2020-06-01 18:58:38 +02:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2020-09-19 22:19:55 +02:00
|
|
|
<th>User</th>
|
2020-06-03 17:57:03 +02:00
|
|
|
<th style="width:60px; min-width: 60px;">Items</th>
|
|
|
|
<th>Attachments</th>
|
2020-09-19 22:19:55 +02:00
|
|
|
<th style="min-width: 120px;">Organizations</th>
|
2020-06-01 18:58:38 +02:00
|
|
|
<th style="width: 140px; min-width: 140px;">Actions</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{#each users}}
|
|
|
|
<tr>
|
|
|
|
<td>
|
2020-09-19 22:19:55 +02:00
|
|
|
<img class="float-left mr-2 rounded identicon" data-src="{{Email}}">
|
|
|
|
<div class="float-left">
|
|
|
|
<strong>{{Name}}</strong>
|
|
|
|
<span class="d-block">{{Email}}</span>
|
2020-11-30 22:00:51 +01:00
|
|
|
<span class="d-block">Created at: {{created_at}}</span>
|
|
|
|
<span class="d-block">Last active: {{last_active}}</span>
|
2020-09-19 22:19:55 +02:00
|
|
|
<span class="d-block">
|
2020-11-30 23:12:56 +01:00
|
|
|
{{#unless user_enabled}}
|
|
|
|
<span class="badge badge-danger mr-2" title="User is disabled">Disabled</span>
|
|
|
|
{{/unless}}
|
2020-09-19 22:19:55 +02:00
|
|
|
{{#if TwoFactorEnabled}}
|
|
|
|
<span class="badge badge-success mr-2" title="2FA is enabled">2FA</span>
|
|
|
|
{{/if}}
|
|
|
|
{{#case _Status 1}}
|
|
|
|
<span class="badge badge-warning mr-2" title="User is invited">Invited</span>
|
|
|
|
{{/case}}
|
|
|
|
{{#if EmailVerified}}
|
|
|
|
<span class="badge badge-success mr-2" title="Email has been verified">Verified</span>
|
|
|
|
{{/if}}
|
|
|
|
</span>
|
|
|
|
</div>
|
2020-06-01 18:58:38 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<span class="d-block">{{cipher_count}}</span>
|
|
|
|
</td>
|
2020-06-03 17:57:03 +02:00
|
|
|
<td>
|
|
|
|
<span class="d-block"><strong>Amount:</strong> {{attachment_count}}</span>
|
|
|
|
{{#if attachment_count}}
|
|
|
|
<span class="d-block"><strong>Size:</strong> {{attachment_size}}</span>
|
|
|
|
{{/if}}
|
|
|
|
</td>
|
2020-06-01 18:58:38 +02:00
|
|
|
<td>
|
|
|
|
{{#each Organizations}}
|
|
|
|
<span class="badge badge-primary" data-orgtype="{{Type}}">{{Name}}</span>
|
|
|
|
{{/each}}
|
|
|
|
</td>
|
|
|
|
<td style="font-size: 90%; text-align: right; padding-right: 15px">
|
2020-05-28 10:42:36 +02:00
|
|
|
{{#if TwoFactorEnabled}}
|
2020-06-01 18:58:38 +02:00
|
|
|
<a class="d-block" href="#" onclick='remove2fa({{jsesc Id}})'>Remove all 2FA</a>
|
2020-05-28 10:42:36 +02:00
|
|
|
{{/if}}
|
2020-06-01 18:58:38 +02:00
|
|
|
<a class="d-block" href="#" onclick='deauthUser({{jsesc Id}})'>Deauthorize sessions</a>
|
|
|
|
<a class="d-block" href="#" onclick='deleteUser({{jsesc Id}}, {{jsesc Email}})'>Delete User</a>
|
2020-11-30 23:12:56 +01:00
|
|
|
{{#if user_enabled}}
|
|
|
|
<a class="d-block" href="#" onclick='disableUser({{jsesc Id}}, {{jsesc Email}})'>Disable User</a>
|
|
|
|
{{else}}
|
|
|
|
<a class="d-block" href="#" onclick='enableUser({{jsesc Id}}, {{jsesc Email}})'>Enable User</a>
|
|
|
|
{{/if}}
|
2020-06-01 18:58:38 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{{/each}}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2020-05-28 10:42:36 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mt-3">
|
2020-06-01 18:58:38 +02:00
|
|
|
<button type="button" class="btn btn-sm btn-danger" onclick="updateRevisions();"
|
2020-05-28 10:42:36 +02:00
|
|
|
title="Force all clients to fetch new data next time they connect. Useful after restoring a backup to remove any stale data.">
|
|
|
|
Force clients to resync
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button type="button" class="btn btn-sm btn-primary float-right" onclick="reload();">Reload users</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="invite-form-block" class="align-items-center p-3 mb-3 text-white-50 bg-secondary rounded shadow">
|
|
|
|
<div>
|
|
|
|
<h6 class="mb-0 text-white">Invite User</h6>
|
|
|
|
<small>Email:</small>
|
|
|
|
|
|
|
|
<form class="form-inline" id="invite-form" onsubmit="inviteUser(); return false;">
|
|
|
|
<input type="email" class="form-control w-50 mr-2" id="email-invite" placeholder="Enter email">
|
|
|
|
<button type="submit" class="btn btn-primary">Invite</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
|
2020-09-19 22:19:55 +02:00
|
|
|
<link rel="stylesheet" href="{{urlpath}}/bwrs_static/datatables.css" />
|
|
|
|
<script src="{{urlpath}}/bwrs_static/jquery-3.5.1.slim.js"></script>
|
|
|
|
<script src="{{urlpath}}/bwrs_static/datatables.js"></script>
|
2020-05-28 10:42:36 +02:00
|
|
|
<script>
|
|
|
|
function deleteUser(id, mail) {
|
|
|
|
var input_mail = prompt("To delete user '" + mail + "', please type the email below")
|
|
|
|
if (input_mail != null) {
|
|
|
|
if (input_mail == mail) {
|
|
|
|
_post("{{urlpath}}/admin/users/" + id + "/delete",
|
|
|
|
"User deleted correctly",
|
|
|
|
"Error deleting user");
|
|
|
|
} else {
|
|
|
|
alert("Wrong email, please try again")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function remove2fa(id) {
|
|
|
|
_post("{{urlpath}}/admin/users/" + id + "/remove-2fa",
|
|
|
|
"2FA removed correctly",
|
|
|
|
"Error removing 2FA");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function deauthUser(id) {
|
|
|
|
_post("{{urlpath}}/admin/users/" + id + "/deauth",
|
|
|
|
"Sessions deauthorized correctly",
|
|
|
|
"Error deauthorizing sessions");
|
|
|
|
return false;
|
|
|
|
}
|
2020-11-30 23:12:56 +01:00
|
|
|
function disableUser(id, mail) {
|
|
|
|
var confirmed = confirm("Are you sure you want to disable user '" + mail + "'? This will also deauthorize their sessions.")
|
|
|
|
if (confirmed) {
|
|
|
|
_post("{{urlpath}}/admin/users/" + id + "/disable",
|
|
|
|
"User disabled successfully",
|
|
|
|
"Error disabling user");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function enableUser(id, mail) {
|
|
|
|
var confirmed = confirm("Are you sure you want to enable user '" + mail + "'?")
|
|
|
|
if (confirmed) {
|
|
|
|
_post("{{urlpath}}/admin/users/" + id + "/enable",
|
|
|
|
"User enabled successfully",
|
|
|
|
"Error enabling user");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2020-05-28 10:42:36 +02:00
|
|
|
function updateRevisions() {
|
|
|
|
_post("{{urlpath}}/admin/users/update_revision",
|
|
|
|
"Success, clients will sync next time they connect",
|
|
|
|
"Error forcing clients to sync");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function inviteUser() {
|
|
|
|
inv = document.getElementById("email-invite");
|
|
|
|
data = JSON.stringify({ "email": inv.value });
|
|
|
|
inv.value = "";
|
|
|
|
_post("{{urlpath}}/admin/invite/", "User invited correctly",
|
|
|
|
"Error inviting user", data);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
let OrgTypes = {
|
|
|
|
"0": { "name": "Owner", "color": "orange" },
|
|
|
|
"1": { "name": "Admin", "color": "blueviolet" },
|
|
|
|
"2": { "name": "User", "color": "blue" },
|
|
|
|
"3": { "name": "Manager", "color": "green" },
|
|
|
|
};
|
|
|
|
|
|
|
|
document.querySelectorAll("img.identicon").forEach(function (e, i) {
|
|
|
|
e.src = identicon(e.dataset.src);
|
|
|
|
});
|
|
|
|
|
|
|
|
document.querySelectorAll("[data-orgtype]").forEach(function (e, i) {
|
|
|
|
let orgtype = OrgTypes[e.dataset.orgtype];
|
|
|
|
e.style.backgroundColor = orgtype.color;
|
|
|
|
e.title = orgtype.name;
|
|
|
|
});
|
2020-09-19 22:19:55 +02:00
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function(event) {
|
|
|
|
$('#users-table').DataTable({
|
|
|
|
"responsive": true,
|
|
|
|
"lengthMenu": [ [-1, 5, 10, 25, 50], ["All", 5, 10, 25, 50] ],
|
|
|
|
"pageLength": -1, // Default show all
|
|
|
|
"columns": [
|
|
|
|
null, // Userdata
|
|
|
|
null, // Items
|
|
|
|
null, // Attachments
|
|
|
|
null, // Organizations
|
|
|
|
{ "searchable": false, "orderable": false }, // Actions
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
2020-05-28 10:42:36 +02:00
|
|
|
</script>
|