From 73c7f22bd1b36b2ce922f8ef00f20e28302693f6 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Wed, 17 Nov 2021 16:49:26 +0000 Subject: [PATCH] messages: add option to show/hide linking on registration In each of the Discord/Telegram/Matrix sections, the "Show on user registration" option can be disabled to hide the "Link xxx" button on the registration form. This is useful is you're only using these registrations for admin purposes. --- config.go | 5 +++++ config/config-base.json | 29 ++++++++++++++++++++++++++++- ts/modules/settings.ts | 2 +- views.go | 16 ++++++++++------ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/config.go b/config.go index 69cc30c..df35b24 100644 --- a/config.go +++ b/config.go @@ -96,6 +96,11 @@ func (app *appContext) loadConfig() error { app.MustSetValue("user_expiry", "email_text", "jfa-go:"+"user-expired.txt") app.MustSetValue("matrix", "topic", "Jellyfin notifications") + app.MustSetValue("matrix", "show_on_reg", "true") + + app.MustSetValue("discord", "show_on_reg", "true") + + app.MustSetValue("telegram", "show_on_reg", "true") app.config.Section("jellyfin").Key("version").SetValue(version) app.config.Section("jellyfin").Key("device").SetValue("jfa-go") diff --git a/config/config-base.json b/config/config-base.json index 0f10c10..382e9ea 100644 --- a/config/config-base.json +++ b/config/config-base.json @@ -579,10 +579,19 @@ "value": false, "description": "Enable signup verification through Discord and the sending of notifications through it.\nSee the jfa-go wiki for setting up a bot." }, + "show_on_reg": { + "name": "Show on user registration", + "required": false, + "requires_restart": true, + "type": "bool", + "depends_true": "enabled", + "value": true, + "description": "Allow users to link their Discord on the registration page." + }, "required": { "name": "Require on sign-up", "required": false, - "required_restart": true, + "requires_restart": true, "depends_true": "enabled", "type": "bool", "value": false, @@ -662,6 +671,15 @@ "value": false, "description": "Enable signup verification through Telegram and the sending of notifications through it.\nSee the jfa-go wiki for setting up a bot." }, + "show_on_reg": { + "name": "Show on user registration", + "required": false, + "requires_restart": true, + "type": "bool", + "depends_true": "enabled", + "value": true, + "description": "Allow users to link their Telegram on the registration page." + }, "required": { "name": "Require on sign-up", "required": false, @@ -709,6 +727,15 @@ "value": false, "description": "Enable signup verification through Matrix and the sending of notifications through it.\nSee the jfa-go wiki for setting up a bot." }, + "show_on_reg": { + "name": "Show on user registration", + "required": false, + "requires_restart": true, + "type": "bool", + "depends_true": "enabled", + "value": true, + "description": "Allow users to link their Matrix on the registration page." + }, "required": { "name": "Require on sign-up", "required": false, diff --git a/ts/modules/settings.ts b/ts/modules/settings.ts index 9112cae..08bfc0b 100644 --- a/ts/modules/settings.ts +++ b/ts/modules/settings.ts @@ -32,7 +32,7 @@ interface Setting { const splitDependant = (section: string, dep: string): string[] => { let parts = dep.split("|"); if (parts.length == 1) { - parts = [section, parts[0]]; + parts = [section, dep]; } return parts }; diff --git a/views.go b/views.go index be8f74e..4356564 100644 --- a/views.go +++ b/views.go @@ -327,6 +327,10 @@ func (app *appContext) InviteProxy(gc *gin.Context) { if strings.Contains(email, "Failed") || !strings.Contains(email, "@") { email = "" } + telegram := telegramEnabled && app.config.Section("telegram").Key("show_on_reg").MustBool(true) + discord := discordEnabled && app.config.Section("discord").Key("show_on_reg").MustBool(true) + matrix := matrixEnabled && app.config.Section("matrix").Key("show_on_reg").MustBool(true) + data := gin.H{ "urlBase": app.getURLBase(gc), "cssClass": app.cssClass, @@ -351,21 +355,21 @@ func (app *appContext) InviteProxy(gc *gin.Context) { "userExpiryMessage": app.storage.lang.Form[lang].Strings.get("yourAccountIsValidUntil"), "langName": lang, "passwordReset": false, - "telegramEnabled": telegramEnabled, - "discordEnabled": discordEnabled, - "matrixEnabled": matrixEnabled, + "telegramEnabled": telegram, + "discordEnabled": discord, + "matrixEnabled": matrix, } - if telegramEnabled { + if telegram { data["telegramPIN"] = app.telegram.NewAuthToken() data["telegramUsername"] = app.telegram.username data["telegramURL"] = app.telegram.link data["telegramRequired"] = app.config.Section("telegram").Key("required").MustBool(false) } - if matrixEnabled { + if matrix { data["matrixRequired"] = app.config.Section("matrix").Key("required").MustBool(false) data["matrixUser"] = app.matrix.userID } - if discordEnabled { + if discord { data["discordPIN"] = app.discord.NewAuthToken() data["discordUsername"] = app.discord.username data["discordRequired"] = app.config.Section("discord").Key("required").MustBool(false)