mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
form: functional "collect on sign-up" setting
was added without functionality by accident in a7aa3fd. This commit adds
the functionality in. Probably some other fixes too.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
window.reCAPTCHASiteKey = "{{ .reCAPTCHASiteKey }}";
|
||||
window.userPageEnabled = {{ .userPageEnabled }};
|
||||
window.userPageAddress = "{{ .userPageAddress }}";
|
||||
window.collectEmail = {{ .collectEmail }};
|
||||
{{ if index . "customSuccessCard" }}
|
||||
window.customSuccessCard = {{ .customSuccessCard }};
|
||||
{{ else }}
|
||||
|
||||
@@ -68,8 +68,10 @@
|
||||
<input type="text" class="input ~neutral @high mt-2 mb-4" placeholder="{{ .strings.username }}" id="create-username" aria-label="{{ .strings.username }}">
|
||||
</label>
|
||||
|
||||
<label class="label supra" for="create-email">{{ .strings.emailAddress }}</label>
|
||||
<input type="email" class="input ~neutral @high mt-2 mb-4" placeholder="{{ .strings.emailAddress }}" id="create-email" aria-label="{{ .strings.emailAddress }}" value="{{ .email }}">
|
||||
<div>
|
||||
<label class="label supra" for="create-email">{{ .strings.emailAddress }}</label>
|
||||
<input type="email" class="input ~neutral @high mt-2 mb-4" placeholder="{{ .strings.emailAddress }}" id="create-email" aria-label="{{ .strings.emailAddress }}" value="{{ .email }}">
|
||||
</div>
|
||||
{{ if .telegramEnabled }}
|
||||
<span class="button ~info @low full-width center mb-4" id="link-telegram">{{ .strings.linkTelegram }} {{ if .telegramRequired }}({{ .strings.required }}){{ end }}</span>
|
||||
{{ end }}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
2
views.go
2
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,
|
||||
|
||||
Reference in New Issue
Block a user