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)