From e6cc7fce1aa38d7d278c3c8542dde40d4b780399 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Mon, 20 Dec 2021 20:44:08 +0000 Subject: [PATCH] form: add setting for changing redirect url for #167, Settings > General (Advanced) > Form success redirect URL. --- config.go | 2 ++ config/config-base.json | 9 +++++++++ views.go | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/config.go b/config.go index 45802d9..1051f93 100644 --- a/config.go +++ b/config.go @@ -39,6 +39,8 @@ func (app *appContext) loadConfig() error { app.MustSetValue("jellyfin", "public_server", app.config.Section("jellyfin").Key("server").String()) + app.MustSetValue("ui", "redirect_url", app.config.Section("jellyfin").Key("public_server").String()) + for _, key := range app.config.Section("files").Keys() { if name := key.Name(); name != "html_templates" && name != "lang_files" { key.SetValue(key.MustString(filepath.Join(app.dataPath, (key.Name() + ".json")))) diff --git a/config/config-base.json b/config/config-base.json index a4e5690..5546d7d 100644 --- a/config/config-base.json +++ b/config/config-base.json @@ -247,6 +247,15 @@ "type": "text", "value": "", "description": "URL base for when running jfa-go with a reverse proxy in a subfolder. include preceding /, e.g \"/accounts\"." + }, + "redirect_url": { + "name": "Form success redirect URL", + "required": false, + "requires_restart": false, + "type": "text", + "value": "", + "advanced": true, + "description": "Set a different URL for the sign-up form to redirect the user to when they've signed up. Default to 'Public Server' or 'Server' in the Jellyfin tab." } } }, diff --git a/views.go b/views.go index dde64fa..d4ec7a3 100644 --- a/views.go +++ b/views.go @@ -160,7 +160,7 @@ func (app *appContext) ResetPassword(gc *gin.Context) { if isInternal && setPassword { data["helpMessage"] = app.config.Section("ui").Key("help_message").String() data["successMessage"] = app.config.Section("ui").Key("success_message").String() - data["jfLink"] = app.config.Section("jellyfin").Key("public_server").String() + data["jfLink"] = app.config.Section("ui").Key("redirect_url").String() data["validate"] = app.config.Section("password_validation").Key("enabled").MustBool(false) data["requirements"] = app.validator.getCriteria() data["strings"] = app.storage.lang.PasswordReset[lang].Strings @@ -313,7 +313,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) { "strings": app.storage.lang.Form[lang].Strings, "successMessage": app.config.Section("ui").Key("success_message").String(), "contactMessage": app.config.Section("ui").Key("contact_message").String(), - "jfLink": app.config.Section("jellyfin").Key("public_server").String(), + "jfLink": app.config.Section("ui").Key("redirect_url").String(), }) inv, ok := app.storage.invites[code] if ok { @@ -337,7 +337,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) { "contactMessage": app.config.Section("ui").Key("contact_message").String(), "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(), + "jfLink": app.config.Section("ui").Key("redirect_url").String(), "validate": app.config.Section("password_validation").Key("enabled").MustBool(false), "requirements": app.validator.getCriteria(), "email": email,