mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-29 12:30:11 +00:00
Compare commits
1 Commits
989ec28ab6
...
91582fe35d
Author | SHA1 | Date | |
---|---|---|---|
|
91582fe35d |
@ -274,18 +274,6 @@
|
||||
"value": false,
|
||||
"advanced": true,
|
||||
"description": "Navigate directly to the above URL instead of needing the user to click \"Continue\"."
|
||||
},
|
||||
"login_appearance": {
|
||||
"name": "Login screen appearance",
|
||||
"required": false,
|
||||
"requires_restart": false,
|
||||
"type": "select",
|
||||
"options": [
|
||||
["clear", "Transparent"],
|
||||
["opaque", "Opaque"]
|
||||
],
|
||||
"value": "clear",
|
||||
"description": "Appearance of the Admin login screen."
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -418,14 +406,6 @@
|
||||
"required": "false",
|
||||
"description": "Click the edit icon next to the \"User Page\" Setting to add custom Markdown messages that will be shown to the user. Note message cards are not private, little effort is required for anyone to view them."
|
||||
},
|
||||
"show_link": {
|
||||
"name": "Show Link on Admin Login page",
|
||||
"required": false,
|
||||
"requires_restart": false,
|
||||
"type": "bool",
|
||||
"value": true,
|
||||
"description": "Whether or not to show a link to the \"My Account\" page on the admin login screen, to direct lost users."
|
||||
},
|
||||
"referrals": {
|
||||
"name": "User Referrals",
|
||||
"required": false,
|
||||
|
@ -15,9 +15,6 @@
|
||||
--border-width-4: 5px;
|
||||
--border-width-8: 8px;
|
||||
font-family: 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||
|
||||
--bg-light: #fff;
|
||||
--bg-dark: #101010;
|
||||
}
|
||||
|
||||
.light {
|
||||
@ -29,11 +26,11 @@
|
||||
}
|
||||
|
||||
.dark body {
|
||||
background-color: var(--bg-dark);
|
||||
background-color: #101010;
|
||||
}
|
||||
|
||||
html:not(.dark) body {
|
||||
background-color: var(--bg-light);
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.dark select, .dark option, .dark input {
|
||||
|
@ -10,24 +10,6 @@
|
||||
background-color: rgba(0,0,0,40%);
|
||||
}
|
||||
|
||||
.wall {
|
||||
position: fixed;
|
||||
z-index: 11;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
html.dark .wall {
|
||||
background-color: var(--bg-dark);
|
||||
}
|
||||
|
||||
html:not(.dark) .wall {
|
||||
background-color: var(--bg-light);
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
float: right;
|
||||
color: #aaa;
|
||||
|
@ -18,7 +18,6 @@
|
||||
window.jfAdminOnly = {{ .jfAdminOnly }};
|
||||
window.jfAllowAll = {{ .jfAllowAll }};
|
||||
window.referralsEnabled = {{ .referralsEnabled }};
|
||||
window.loginAppearance = "{{ .loginAppearance }}";
|
||||
</script>
|
||||
<title>Admin - jfa-go</title>
|
||||
{{ template "header.html" . }}
|
||||
@ -466,7 +465,7 @@
|
||||
</div>
|
||||
{{ if .userPageEnabled }}
|
||||
<div class="top-4 right-4 absolute">
|
||||
<a class="button ~info" href="{{ .urlBase }}/my/account"><i class="ri-account-circle-fill mr-2"></i>{{ .strings.myAccount }}</a>
|
||||
<a class="button ~info" href="/my/account"><i class="ri-account-circle-fill mr-2"></i>{{ .strings.myAccount }}</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
<div class="page-container">
|
||||
|
@ -7,14 +7,6 @@
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if index . "userPageEnabled" }}
|
||||
{{ if and .userPageEnabled .showUserPageLink }}
|
||||
<div class="card mx-2 flex-initial w-[100%] xl:w-[35%] mb-4 xl:mb-0 dark:~d_neutral @low content">
|
||||
<span class="heading row">{{ .strings.loginNotAdmin }}</span>
|
||||
<a class="button ~info h-12 w-100" href="{{ .urlBase }}/my/account"><i class="ri-account-circle-fill mr-2"></i>{{ .strings.myAccount }}</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<form class="card mx-2 flex-auto form-login w-[100%] xl:w-[55%] mb-0" href="">
|
||||
<span class="heading">{{ .strings.login }}</span>
|
||||
<input type="text" class="field input ~neutral @high mt-4 mb-2" placeholder="{{ .strings.username }}" id="login-user">
|
||||
|
@ -123,8 +123,7 @@
|
||||
"userPageLogin": "User Page: Login",
|
||||
"userPagePage": "User Page: Page",
|
||||
"buildTime": "Build Time",
|
||||
"builtBy": "Built By",
|
||||
"loginNotAdmin": "Not an Admin?"
|
||||
"builtBy": "Built By"
|
||||
},
|
||||
"notifications": {
|
||||
"changedEmailAddress": "Changed email address of {n}.",
|
||||
|
39
router.go
39
router.go
@ -160,11 +160,12 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
||||
|
||||
api := router.Group("/", app.webAuth())
|
||||
|
||||
var user *gin.RouterGroup
|
||||
if userPageEnabled {
|
||||
user = router.Group("/my", app.userAuth())
|
||||
}
|
||||
|
||||
for _, p := range routePrefixes {
|
||||
var user *gin.RouterGroup
|
||||
if userPageEnabled {
|
||||
user = router.Group(p+"/my", app.userAuth())
|
||||
}
|
||||
router.POST(p+"/logout", app.Logout)
|
||||
api.DELETE(p+"/users", app.DeleteUsers)
|
||||
api.GET(p+"/users", app.GetUsers)
|
||||
@ -233,22 +234,22 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
||||
}
|
||||
|
||||
if userPageEnabled {
|
||||
user.GET("/details", app.MyDetails)
|
||||
user.POST("/contact", app.SetMyContactMethods)
|
||||
user.POST("/logout", app.LogoutUser)
|
||||
user.POST("/email", app.ModifyMyEmail)
|
||||
user.GET("/discord/invite", app.MyDiscordServerInvite)
|
||||
user.GET("/pin/:service", app.GetMyPIN)
|
||||
user.GET("/discord/verified/:pin", app.MyDiscordVerifiedInvite)
|
||||
user.GET("/telegram/verified/:pin", app.MyTelegramVerifiedInvite)
|
||||
user.POST("/matrix/user", app.MatrixSendMyPIN)
|
||||
user.GET("/matrix/verified/:userID/:pin", app.MatrixCheckMyPIN)
|
||||
user.DELETE("/discord", app.UnlinkMyDiscord)
|
||||
user.DELETE("/telegram", app.UnlinkMyTelegram)
|
||||
user.DELETE("/matrix", app.UnlinkMyMatrix)
|
||||
user.POST("/password", app.ChangeMyPassword)
|
||||
user.GET(p+"/details", app.MyDetails)
|
||||
user.POST(p+"/contact", app.SetMyContactMethods)
|
||||
user.POST(p+"/logout", app.LogoutUser)
|
||||
user.POST(p+"/email", app.ModifyMyEmail)
|
||||
user.GET(p+"/discord/invite", app.MyDiscordServerInvite)
|
||||
user.GET(p+"/pin/:service", app.GetMyPIN)
|
||||
user.GET(p+"/discord/verified/:pin", app.MyDiscordVerifiedInvite)
|
||||
user.GET(p+"/telegram/verified/:pin", app.MyTelegramVerifiedInvite)
|
||||
user.POST(p+"/matrix/user", app.MatrixSendMyPIN)
|
||||
user.GET(p+"/matrix/verified/:userID/:pin", app.MatrixCheckMyPIN)
|
||||
user.DELETE(p+"/discord", app.UnlinkMyDiscord)
|
||||
user.DELETE(p+"/telegram", app.UnlinkMyTelegram)
|
||||
user.DELETE(p+"/matrix", app.UnlinkMyMatrix)
|
||||
user.POST(p+"/password", app.ChangeMyPassword)
|
||||
if app.config.Section("user_page").Key("referrals").MustBool(false) {
|
||||
user.GET("/referral", app.GetMyReferral)
|
||||
user.GET(p+"/referral", app.GetMyReferral)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ window.onpopstate = (event: PopStateEvent) => {
|
||||
window.tabs.switch(event.state);
|
||||
}
|
||||
|
||||
const login = new Login(window.modals.login as Modal, "/", window.loginAppearance);
|
||||
const login = new Login(window.modals.login as Modal, "/");
|
||||
login.onLogin = () => {
|
||||
console.log("Logged in.");
|
||||
window.updater = new Updater();
|
||||
|
@ -8,21 +8,13 @@ export class Login {
|
||||
private _endpoint: string;
|
||||
private _onLogin: (username: string, password: string) => void;
|
||||
private _logoutButton: HTMLElement = null;
|
||||
private _wall: HTMLElement;
|
||||
private _hasOpacityWall: boolean = false;
|
||||
|
||||
constructor(modal: Modal, endpoint: string, appearance: string) {
|
||||
constructor(modal: Modal, endpoint: string) {
|
||||
this._endpoint = endpoint;
|
||||
this._url = window.URLBase + endpoint;
|
||||
if (this._url[this._url.length-1] != '/') this._url += "/";
|
||||
|
||||
this._modal = modal;
|
||||
if (appearance == "opaque") {
|
||||
this._hasOpacityWall = true;
|
||||
this._wall = document.createElement("div");
|
||||
this._wall.classList.add("wall");
|
||||
this._modal.asElement().parentElement.appendChild(this._wall);
|
||||
}
|
||||
this._form = this._modal.asElement().querySelector(".form-login") as HTMLFormElement;
|
||||
this._form.onsubmit = (event: SubmitEvent) => {
|
||||
event.preventDefault();
|
||||
@ -94,7 +86,6 @@ export class Login {
|
||||
if (this._onLogin) {
|
||||
this._onLogin(username, password);
|
||||
}
|
||||
if (this._hasOpacityWall) this._wall.remove();
|
||||
this._modal.close();
|
||||
if (this._logoutButton != null)
|
||||
this._logoutButton.classList.remove("unfocused");
|
||||
|
@ -41,7 +41,6 @@ declare interface Window {
|
||||
jfAdminOnly: boolean;
|
||||
jfAllowAll: boolean;
|
||||
referralsEnabled: boolean;
|
||||
loginAppearance: string;
|
||||
}
|
||||
|
||||
declare interface Update {
|
||||
|
@ -556,6 +556,7 @@ changePasswordButton.addEventListener("click", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
// FIXME: Submit & Validate
|
||||
|
||||
document.addEventListener("details-reload", () => {
|
||||
_get("/my/details", null, (req: XMLHttpRequest) => {
|
||||
@ -644,7 +645,7 @@ document.addEventListener("details-reload", () => {
|
||||
});
|
||||
});
|
||||
|
||||
const login = new Login(window.modals.login as Modal, "/my/", "opaque");
|
||||
const login = new Login(window.modals.login as Modal, "/my/");
|
||||
login.onLogin = () => {
|
||||
console.log("Logged in.");
|
||||
document.querySelector(".page-container").classList.remove("unfocused");
|
||||
|
2
views.go
2
views.go
@ -175,9 +175,7 @@ func (app *appContext) AdminPage(gc *gin.Context) {
|
||||
"jfAdminOnly": jfAdminOnly,
|
||||
"jfAllowAll": jfAllowAll,
|
||||
"userPageEnabled": app.config.Section("user_page").Key("enabled").MustBool(false),
|
||||
"showUserPageLink": app.config.Section("user_page").Key("show_link").MustBool(true),
|
||||
"referralsEnabled": app.config.Section("user_page").Key("enabled").MustBool(false) && app.config.Section("user_page").Key("referrals").MustBool(false),
|
||||
"loginAppearance": app.config.Section("ui").Key("login_appearance").MustString("clear"),
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user