mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 09:00:10 +00:00
userpage: show placeholder message card for admins
This commit is contained in:
parent
cc4a97db28
commit
e7f7dcbb78
@ -28,6 +28,14 @@ func (app *appContext) MyDetails(gc *gin.Context) {
|
||||
}
|
||||
resp.Username = user.Name
|
||||
resp.Admin = user.Policy.IsAdministrator
|
||||
resp.AccountsAdmin = false
|
||||
if !app.config.Section("ui").Key("allow_all").MustBool(false) {
|
||||
adminOnly := app.config.Section("ui").Key("admin_only").MustBool(true)
|
||||
if emailStore, ok := app.storage.GetEmailsKey(resp.Id); ok {
|
||||
resp.AccountsAdmin = emailStore.Admin
|
||||
}
|
||||
resp.AccountsAdmin = resp.AccountsAdmin || (adminOnly && resp.Admin)
|
||||
}
|
||||
resp.Disabled = user.Policy.IsDisabled
|
||||
|
||||
if exp, ok := app.storage.users[user.ID]; ok {
|
||||
|
@ -85,7 +85,7 @@
|
||||
</div>
|
||||
{{ if index . "PageMessageEnabled" }}
|
||||
{{ if .PageMessageEnabled }}
|
||||
<div class="card @low dark:~d_neutral content">
|
||||
<div class="card @low dark:~d_neutral content" id="card-message">
|
||||
{{ .PageMessageContent }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
@ -23,7 +23,9 @@
|
||||
"welcomeUser": "Welcome, {user}!",
|
||||
"addContactMethod": "Add Contact Method",
|
||||
"editContactMethod": "Edit Contact Method",
|
||||
"joinTheServer": "Join the server:"
|
||||
"joinTheServer": "Join the server:",
|
||||
"customMessagePlaceholderHeader": "Customize this card",
|
||||
"customMessagePlaceholderContent": "Click the user page edit button in settings to customize this card, or show one on the login screen, and don't worry, the user can't see this."
|
||||
},
|
||||
"notifications": {
|
||||
"errorUserExists": "User already exists.",
|
||||
|
19
models.go
19
models.go
@ -376,15 +376,16 @@ type ReCaptchaResponseDTO struct {
|
||||
|
||||
// MyDetailsDTO is sent to the user page to personalize it for the user.
|
||||
type MyDetailsDTO struct {
|
||||
Id string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Expiry int64 `json:"expiry"`
|
||||
Admin bool `json:"admin"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Email *MyDetailsContactMethodsDTO `json:"email,omitempty"`
|
||||
Discord *MyDetailsContactMethodsDTO `json:"discord,omitempty"`
|
||||
Telegram *MyDetailsContactMethodsDTO `json:"telegram,omitempty"`
|
||||
Matrix *MyDetailsContactMethodsDTO `json:"matrix,omitempty"`
|
||||
Id string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Expiry int64 `json:"expiry"`
|
||||
Admin bool `json:"admin"`
|
||||
AccountsAdmin bool `json:"accounts_admin"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Email *MyDetailsContactMethodsDTO `json:"email,omitempty"`
|
||||
Discord *MyDetailsContactMethodsDTO `json:"discord,omitempty"`
|
||||
Telegram *MyDetailsContactMethodsDTO `json:"telegram,omitempty"`
|
||||
Matrix *MyDetailsContactMethodsDTO `json:"matrix,omitempty"`
|
||||
}
|
||||
|
||||
type MyDetailsContactMethodsDTO struct {
|
||||
|
18
ts/user.ts
18
ts/user.ts
@ -62,6 +62,7 @@ interface MyDetails {
|
||||
username: string;
|
||||
expiry: number;
|
||||
admin: boolean;
|
||||
accounts_admin: boolean;
|
||||
disabled: boolean;
|
||||
email?: MyDetailsContactMethod;
|
||||
discord?: MyDetailsContactMethod;
|
||||
@ -388,6 +389,23 @@ document.addEventListener("details-reload", () => {
|
||||
}
|
||||
|
||||
expiryCard.expiry = details.expiry;
|
||||
|
||||
|
||||
if (details.accounts_admin) {
|
||||
let messageCard = document.getElementById("card-message")
|
||||
if (typeof(messageCard) == "undefined" || messageCard == null) {
|
||||
messageCard = document.createElement("div");
|
||||
messageCard.classList.add("card", "@low", "dark:~d_neutral", "content");
|
||||
messageCard.id = "card-message";
|
||||
contactCard.parentElement.appendChild(messageCard);
|
||||
}
|
||||
if (!messageCard.textContent) {
|
||||
messageCard.innerHTML = `
|
||||
<span class="heading mb-2">${window.lang.strings("customMessagePlaceholderHeader")} ✏️ </span>
|
||||
<span class="block">${window.lang.strings("customMessagePlaceholderContent")}</span>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user