Skip to content

Commit

Permalink
messages: add option to show/hide linking on registration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hrfee committed Nov 17, 2021
1 parent e7ca335 commit 73c7f22
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
5 changes: 5 additions & 0 deletions config.go
Expand Up @@ -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")
Expand Down
29 changes: 28 additions & 1 deletion config/config-base.json
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ts/modules/settings.ts
Expand Up @@ -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
};
Expand Down
16 changes: 10 additions & 6 deletions views.go
Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 73c7f22

Please sign in to comment.