diff --git a/config.go b/config.go index df6daa4..44a198f 100644 --- a/config.go +++ b/config.go @@ -266,6 +266,11 @@ func NewConfig(configPathOrContents any, dataPath string, logs LoggerSet) (*Conf config.Section("discord").Key("start_command").SetValue(strings.TrimPrefix(strings.TrimPrefix(sc, "/"), "!")) config.MustSetValue("email", "collect", "true") + collect := config.Section("email").Key("collect").MustBool(true) + required := config.Section("email").Key("required").MustBool(false) && collect + config.Section("email").Key("required").SetValue(strconv.FormatBool(required)) + unique := config.Section("email").Key("require_unique").MustBool(false) && collect + config.Section("email").Key("require_unique").SetValue(strconv.FormatBool(unique)) config.MustSetValue("matrix", "topic", "Jellyfin notifications") config.MustSetValue("matrix", "show_on_reg", "true") diff --git a/config/config-base.yaml b/config/config-base.yaml index 7d486d3..40a9e29 100644 --- a/config/config-base.yaml +++ b/config/config-base.yaml @@ -776,9 +776,27 @@ sections: - ["en-us", "English (US)"] value: en-us description: Default email language. Submit a PR on github if you'd like to translate. + - setting: collect + name: Collect on sign-up + type: bool + value: true + description: Ask for an email address on the sign-up form. + - setting: required + name: Require on sign-up + depends_true: collect + type: bool + value: false + description: Require an email address on sign-up. + - setting: require_unique + name: Require unique address + requires_restart: true + depends_true: method + type: bool + value: false + description: Disables using the same address on multiple accounts. - setting: no_username name: Use email addresses as username - depends_true: method + depends_true: collect type: bool value: false description: Use email address from invite form as username on Jellyfin. @@ -811,25 +829,6 @@ sections: type: bool value: false description: Send emails as plain text instead of HTML. - - setting: collect - name: Collect on sign-up - depends_true: method - type: bool - value: true - description: Ask for an email address on the sign-up form. - - setting: required - name: Require on sign-up - depends_true: collect - type: bool - value: false - description: Require an email address on sign-up. - - setting: require_unique - name: Require unique address - requires_restart: true - depends_true: method - type: bool - value: false - description: Disables using the same address on multiple accounts. - setting: test_note name: 'Test your settings:' type: note @@ -1483,7 +1482,7 @@ sections: name: Email confirmation description: If enabled, a user will be sent an email confirmation link to ensure their password is right before they can make an account. - depends_true: email|method + depends_true: email|collect settings: - setting: enabled name: Enabled diff --git a/html/form-base.html b/html/form-base.html index 77e6a36..f21475e 100644 --- a/html/form-base.html +++ b/html/form-base.html @@ -27,6 +27,7 @@ window.reCAPTCHASiteKey = "{{ .reCAPTCHASiteKey }}"; window.userPageEnabled = {{ .userPageEnabled }}; window.userPageAddress = "{{ .userPageAddress }}"; + window.collectEmail = {{ .collectEmail }}; {{ if index . "customSuccessCard" }} window.customSuccessCard = {{ .customSuccessCard }}; {{ else }} diff --git a/html/form.html b/html/form.html index 336d21d..acfbf29 100644 --- a/html/form.html +++ b/html/form.html @@ -68,8 +68,10 @@ - - +
+ + +
{{ if .telegramEnabled }} {{ .strings.linkTelegram }} {{ if .telegramRequired }}({{ .strings.required }}){{ end }} {{ end }} diff --git a/jellyseerr-d.go b/jellyseerr-d.go index 6e6b63a..c750419 100644 --- a/jellyseerr-d.go +++ b/jellyseerr-d.go @@ -2,6 +2,7 @@ package main import ( "strconv" + "strings" "time" "github.com/hrfee/jfa-go/jellyseerr" @@ -28,7 +29,12 @@ func (app *appContext) SynchronizeJellyseerrUser(jfID string) { if ok && email.Addr != "" && user.Email != email.Addr { err = app.js.ModifyMainUserSettings(jfID, jellyseerr.MainUserSettings{Email: email.Addr}) if err != nil { - app.err.Printf(lm.FailedSetEmailAddress, lm.Jellyseerr, jfID, err) + if strings.Contains(err.Error(), "INVALID_EMAIL") { + app.err.Printf(lm.FailedSetEmailAddress, lm.Jellyseerr, jfID, err.Error()+"\""+email.Addr+"\"") + } else { + + app.err.Printf(lm.FailedSetEmailAddress, lm.Jellyseerr, jfID, err) + } } else { contactMethods[jellyseerr.FieldEmailEnabled] = email.Contact } diff --git a/ts/form.ts b/ts/form.ts index 7ec413c..cb18611 100644 --- a/ts/form.ts +++ b/ts/form.ts @@ -39,6 +39,7 @@ interface formWindow extends GlobalWindow { userPageEnabled: boolean; userPageAddress: string; customSuccessCard: boolean; + collectEmail: boolean; } loadLangSelector("form"); @@ -171,7 +172,13 @@ const submitSpan = form.querySelector("span.submit") as HTMLSpanElement; const submitText = submitSpan.textContent; let usernameField = document.getElementById("create-username") as HTMLInputElement; const emailField = document.getElementById("create-email") as HTMLInputElement; -if (!window.usernameEnabled) { usernameField.parentElement.remove(); usernameField = emailField; } +window.emailRequired &&= window.collectEmail; +if (!window.usernameEnabled) { + usernameField.parentElement.remove(); usernameField = emailField; +} else if (!window.collectEmail) { + emailField.parentElement.classList.add("unfocused"); + emailField.value = ""; +} const passwordField = document.getElementById("create-password") as HTMLInputElement; const rePasswordField = document.getElementById("create-reenter-password") as HTMLInputElement; diff --git a/views.go b/views.go index 3609fc5..2e1acee 100644 --- a/views.go +++ b/views.go @@ -299,6 +299,7 @@ func (app *appContext) ResetPassword(gc *gin.Context) { "strings": app.storage.lang.PasswordReset[lang].Strings, "success": false, "customSuccessCard": false, + "collectEmail": app.config.Section("email").Key("collect").MustBool(true), } pwr, isInternal := app.internalPWRs[pin] // if isInternal && setPassword { @@ -761,6 +762,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) { "validate": app.config.Section("password_validation").Key("enabled").MustBool(false), "requirements": app.validator.getCriteria(), "email": email, + "collectEmail": app.config.Section("email").Key("collect").MustBool(true), "username": !app.config.Section("email").Key("no_username").MustBool(false), "strings": app.storage.lang.User[lang].Strings, "validationStrings": app.storage.lang.User[lang].validationStringsJSON,