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.
This commit is contained in:
Harvey Tindall 2021-11-17 16:49:26 +00:00
parent e7ca335d83
commit 73c7f22bd1
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
4 changed files with 44 additions and 8 deletions

View File

@ -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")

View File

@ -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,

View File

@ -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
};

View File

@ -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)