mirror of
https://github.com/ViViDboarder/bitwarden_rs.git
synced 2024-11-05 04:46:36 +00:00
Use absolute paths in the admin page
This commit is contained in:
parent
0a3008e753
commit
2f4a9865e1
@ -60,7 +60,7 @@ fn admin_path() -> String {
|
|||||||
fn admin_login(flash: Option<FlashMessage>) -> ApiResult<Html<String>> {
|
fn admin_login(flash: Option<FlashMessage>) -> ApiResult<Html<String>> {
|
||||||
// If there is an error, show it
|
// If there is an error, show it
|
||||||
let msg = flash.map(|msg| format!("{}: {}", msg.name(), msg.msg()));
|
let msg = flash.map(|msg| format!("{}: {}", msg.name(), msg.msg()));
|
||||||
let json = json!({"page_content": "admin/login", "version": VERSION, "error": msg});
|
let json = json!({"page_content": "admin/login", "version": VERSION, "error": msg, "urlpath": CONFIG.domain_path()});
|
||||||
|
|
||||||
// Return the page
|
// Return the page
|
||||||
let text = CONFIG.render_template(BASE_TEMPLATE, &json)?;
|
let text = CONFIG.render_template(BASE_TEMPLATE, &json)?;
|
||||||
@ -115,6 +115,7 @@ struct AdminTemplateData {
|
|||||||
config: Value,
|
config: Value,
|
||||||
can_backup: bool,
|
can_backup: bool,
|
||||||
logged_in: bool,
|
logged_in: bool,
|
||||||
|
urlpath: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AdminTemplateData {
|
impl AdminTemplateData {
|
||||||
@ -126,6 +127,7 @@ impl AdminTemplateData {
|
|||||||
config: CONFIG.prepare_json(),
|
config: CONFIG.prepare_json(),
|
||||||
can_backup: *CAN_BACKUP,
|
can_backup: *CAN_BACKUP,
|
||||||
logged_in: true,
|
logged_in: true,
|
||||||
|
urlpath: CONFIG.domain_path(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<title>Bitwarden_rs Admin Panel</title>
|
<title>Bitwarden_rs Admin Panel</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="bwrs_static/bootstrap.css" />
|
<link rel="stylesheet" href="{{urlpath}}/bwrs_static/bootstrap.css" />
|
||||||
<script src="bwrs_static/bootstrap-native-v4.js"></script>
|
<script src="{{urlpath}}/bwrs_static/bootstrap-native-v4.js"></script>
|
||||||
<script src="bwrs_static/md5.js"></script>
|
<script src="{{urlpath}}/bwrs_static/md5.js"></script>
|
||||||
<script src="bwrs_static/identicon.js"></script>
|
<script src="{{urlpath}}/bwrs_static/identicon.js"></script>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
padding-top: 70px;
|
padding-top: 70px;
|
||||||
@ -38,10 +38,10 @@
|
|||||||
<div class="navbar-collapse">
|
<div class="navbar-collapse">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
<a class="nav-link" href="admin">Admin Panel</a>
|
<a class="nav-link" href="{{urlpath}}/admin">Admin Panel</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href=".">Vault</a>
|
<a class="nav-link" href="{{urlpath}}/">Vault</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
{{#if logged_in}}
|
{{#if logged_in}}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="admin/logout">Log Out</a>
|
<a class="nav-link" href="{{urlpath}}/admin/logout">Log Out</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<main class="container">
|
<main class="container">
|
||||||
<div id="users-block" class="my-3 p-3 bg-white rounded shadow">
|
<div id="users-block" class="my-3 p-3 bg-white rounded shadow">
|
||||||
<h6 class="border-bottom pb-2 mb-0">Registered Users</h6>
|
<h6 class="border-bottom pb-2 mb-0">Registered Users {{urlpath}}</h6>
|
||||||
|
|
||||||
<div id="users-list">
|
<div id="users-list">
|
||||||
{{#each users}}
|
{{#each users}}
|
||||||
@ -19,7 +19,7 @@
|
|||||||
<span class="d-block">{{Email}}</span>
|
<span class="d-block">{{Email}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<strong> Organizations:</strong>
|
<strong> Organizations: </strong>
|
||||||
<span class="d-block">
|
<span class="d-block">
|
||||||
{{#each Organizations}}
|
{{#each Organizations}}
|
||||||
<span class="badge badge-primary" data-orgtype="{{Type}}">{{Name}}</span>
|
<span class="badge badge-primary" data-orgtype="{{Type}}">{{Name}}</span>
|
||||||
@ -225,7 +225,7 @@
|
|||||||
var input_mail = prompt("To delete user '" + mail + "', please type the email below")
|
var input_mail = prompt("To delete user '" + mail + "', please type the email below")
|
||||||
if (input_mail != null) {
|
if (input_mail != null) {
|
||||||
if (input_mail == mail) {
|
if (input_mail == mail) {
|
||||||
_post("admin/users/" + id + "/delete",
|
_post("{{urlpath}}/admin/users/" + id + "/delete",
|
||||||
"User deleted correctly",
|
"User deleted correctly",
|
||||||
"Error deleting user");
|
"Error deleting user");
|
||||||
} else {
|
} else {
|
||||||
@ -235,19 +235,19 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function remove2fa(id) {
|
function remove2fa(id) {
|
||||||
_post("admin/users/" + id + "/remove-2fa",
|
_post("{{urlpath}}/admin/users/" + id + "/remove-2fa",
|
||||||
"2FA removed correctly",
|
"2FA removed correctly",
|
||||||
"Error removing 2FA");
|
"Error removing 2FA");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function deauthUser(id) {
|
function deauthUser(id) {
|
||||||
_post("admin/users/" + id + "/deauth",
|
_post("{{urlpath}}/admin/users/" + id + "/deauth",
|
||||||
"Sessions deauthorized correctly",
|
"Sessions deauthorized correctly",
|
||||||
"Error deauthorizing sessions");
|
"Error deauthorizing sessions");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function updateRevisions() {
|
function updateRevisions() {
|
||||||
_post("admin/users/update_revision",
|
_post("{{urlpath}}/admin/users/update_revision",
|
||||||
"Success, clients will sync next time they connect",
|
"Success, clients will sync next time they connect",
|
||||||
"Error forcing clients to sync");
|
"Error forcing clients to sync");
|
||||||
return false;
|
return false;
|
||||||
@ -256,7 +256,7 @@
|
|||||||
inv = document.getElementById("email-invite");
|
inv = document.getElementById("email-invite");
|
||||||
data = JSON.stringify({ "email": inv.value });
|
data = JSON.stringify({ "email": inv.value });
|
||||||
inv.value = "";
|
inv.value = "";
|
||||||
_post("admin/invite/", "User invited correctly",
|
_post("{{urlpath}}/admin/invite/", "User invited correctly",
|
||||||
"Error inviting user", data);
|
"Error inviting user", data);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@
|
|||||||
}
|
}
|
||||||
function saveConfig() {
|
function saveConfig() {
|
||||||
data = JSON.stringify(getFormData());
|
data = JSON.stringify(getFormData());
|
||||||
_post("admin/config/", "Config saved correctly",
|
_post("{{urlpath}}/admin/config/", "Config saved correctly",
|
||||||
"Error saving config", data);
|
"Error saving config", data);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@
|
|||||||
var input = prompt("This will remove all user configurations, and restore the defaults and the " +
|
var input = prompt("This will remove all user configurations, and restore the defaults and the " +
|
||||||
"values set by the environment. This operation could be dangerous. Type 'DELETE' to proceed:");
|
"values set by the environment. This operation could be dangerous. Type 'DELETE' to proceed:");
|
||||||
if (input === "DELETE") {
|
if (input === "DELETE") {
|
||||||
_post("admin/config/delete",
|
_post("{{urlpath}}/admin/config/delete",
|
||||||
"Config deleted correctly",
|
"Config deleted correctly",
|
||||||
"Error deleting config");
|
"Error deleting config");
|
||||||
} else {
|
} else {
|
||||||
@ -296,7 +296,7 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function backupDatabase() {
|
function backupDatabase() {
|
||||||
_post("admin/config/backup_db",
|
_post("{{urlpath}}/admin/config/backup_db",
|
||||||
"Backup created successfully",
|
"Backup created successfully",
|
||||||
"Error creating backup");
|
"Error creating backup");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user