2020-07-29 21:11:28 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2020-10-22 16:50:40 +00:00
|
|
|
"strings"
|
2020-08-16 12:36:54 +00:00
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
2020-07-29 21:11:28 +00:00
|
|
|
)
|
|
|
|
|
2020-11-22 16:36:43 +00:00
|
|
|
func gcHTML(gc *gin.Context, code int, file string, templ gin.H) {
|
|
|
|
gc.Header("Cache-Control", "no-cache")
|
|
|
|
gc.HTML(code, file, templ)
|
|
|
|
}
|
|
|
|
|
2020-08-16 12:36:54 +00:00
|
|
|
func (app *appContext) AdminPage(gc *gin.Context) {
|
|
|
|
bs5 := app.config.Section("ui").Key("bs5").MustBool(false)
|
|
|
|
emailEnabled, _ := app.config.Section("invite_emails").Key("enabled").Bool()
|
|
|
|
notificationsEnabled, _ := app.config.Section("notifications").Key("enabled").Bool()
|
2020-09-05 16:32:49 +00:00
|
|
|
ombiEnabled := app.config.Section("ombi").Key("enabled").MustBool(false)
|
2020-11-22 16:36:43 +00:00
|
|
|
gcHTML(gc, http.StatusOK, "admin.html", gin.H{
|
|
|
|
"urlBase": app.URLBase,
|
2020-07-29 21:11:28 +00:00
|
|
|
"bs5": bs5,
|
2020-08-16 12:36:54 +00:00
|
|
|
"cssFile": app.cssFile,
|
2020-07-29 21:11:28 +00:00
|
|
|
"contactMessage": "",
|
|
|
|
"email_enabled": emailEnabled,
|
|
|
|
"notifications": notificationsEnabled,
|
2020-08-31 14:29:35 +00:00
|
|
|
"version": VERSION,
|
|
|
|
"commit": COMMIT,
|
2020-09-05 16:32:49 +00:00
|
|
|
"ombiEnabled": ombiEnabled,
|
2020-09-17 23:59:59 +00:00
|
|
|
"username": !app.config.Section("email").Key("no_username").MustBool(false),
|
2020-07-29 21:11:28 +00:00
|
|
|
})
|
|
|
|
}
|
2020-07-31 11:48:37 +00:00
|
|
|
|
2020-08-16 12:36:54 +00:00
|
|
|
func (app *appContext) InviteProxy(gc *gin.Context) {
|
2020-07-31 11:48:37 +00:00
|
|
|
code := gc.Param("invCode")
|
2020-07-31 12:03:36 +00:00
|
|
|
/* Don't actually check if the invite is valid, just if it exists, just so the page loads quicker. Invite is actually checked on submit anyway. */
|
2020-08-16 12:36:54 +00:00
|
|
|
// if app.checkInvite(code, false, "") {
|
|
|
|
if _, ok := app.storage.invites[code]; ok {
|
|
|
|
email := app.storage.invites[code].Email
|
2020-10-22 16:50:40 +00:00
|
|
|
if strings.Contains(email, "Failed") {
|
|
|
|
email = ""
|
|
|
|
}
|
2020-11-22 16:36:43 +00:00
|
|
|
gcHTML(gc, http.StatusOK, "form-loader.html", gin.H{
|
|
|
|
"urlBase": app.URLBase,
|
2020-08-16 12:36:54 +00:00
|
|
|
"cssFile": app.cssFile,
|
2020-09-23 19:14:16 +00:00
|
|
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
2020-08-16 12:36:54 +00:00
|
|
|
"helpMessage": app.config.Section("ui").Key("help_message").String(),
|
|
|
|
"successMessage": app.config.Section("ui").Key("success_message").String(),
|
|
|
|
"jfLink": app.config.Section("jellyfin").Key("public_server").String(),
|
|
|
|
"validate": app.config.Section("password_validation").Key("enabled").MustBool(false),
|
|
|
|
"requirements": app.validator.getCriteria(),
|
2020-07-31 11:48:37 +00:00
|
|
|
"email": email,
|
2020-10-22 16:50:40 +00:00
|
|
|
"settings": map[string]bool{
|
|
|
|
"bs5": app.config.Section("ui").Key("bs5").MustBool(false),
|
|
|
|
"username": !app.config.Section("email").Key("no_username").MustBool(false),
|
|
|
|
},
|
2020-10-30 22:51:47 +00:00
|
|
|
"lang": app.storage.lang.Form["strings"],
|
2020-07-31 11:48:37 +00:00
|
|
|
})
|
|
|
|
} else {
|
2020-11-22 16:36:43 +00:00
|
|
|
gcHTML(gc, 404, "invalidCode.html", gin.H{
|
2020-08-16 12:36:54 +00:00
|
|
|
"bs5": app.config.Section("ui").Key("bs5").MustBool(false),
|
|
|
|
"cssFile": app.cssFile,
|
2020-09-23 19:14:16 +00:00
|
|
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
2020-07-31 12:03:36 +00:00
|
|
|
})
|
2020-07-31 11:48:37 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-31 12:03:36 +00:00
|
|
|
|
2020-08-16 12:36:54 +00:00
|
|
|
func (app *appContext) NoRouteHandler(gc *gin.Context) {
|
2020-11-22 16:36:43 +00:00
|
|
|
gcHTML(gc, 404, "404.html", gin.H{
|
2020-08-16 12:36:54 +00:00
|
|
|
"bs5": app.config.Section("ui").Key("bs5").MustBool(false),
|
|
|
|
"cssFile": app.cssFile,
|
|
|
|
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
2020-07-31 12:03:36 +00:00
|
|
|
})
|
|
|
|
}
|