mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
parent
9fff5781f4
commit
0fd4f516b1
5
api.go
5
api.go
@ -644,6 +644,11 @@ func (app *appContext) NewUser(gc *gin.Context) {
|
|||||||
gc.JSON(200, validation)
|
gc.JSON(200, validation)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if emailEnabled && app.config.Section("email").Key("required").MustBool(false) && !strings.Contains(req.Email, "@") {
|
||||||
|
app.info.Printf("%s: New user failed: Email Required", req.Code)
|
||||||
|
respond(400, "errorNoEmail", gc)
|
||||||
|
return
|
||||||
|
}
|
||||||
f, success := app.newUser(req, false)
|
f, success := app.newUser(req, false)
|
||||||
if !success {
|
if !success {
|
||||||
f(gc)
|
f(gc)
|
||||||
|
@ -458,6 +458,15 @@
|
|||||||
"type": "bool",
|
"type": "bool",
|
||||||
"value": false,
|
"value": false,
|
||||||
"description": "Send emails as plain text instead of HTML."
|
"description": "Send emails as plain text instead of HTML."
|
||||||
|
},
|
||||||
|
"required": {
|
||||||
|
"name": "Require on sign-up",
|
||||||
|
"required": false,
|
||||||
|
"requires_restart": false,
|
||||||
|
"depends_true": "method",
|
||||||
|
"type": "bool",
|
||||||
|
"value": false,
|
||||||
|
"description": "Require an email address on sign-up."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
window.telegramEnabled = {{ .telegramEnabled }};
|
window.telegramEnabled = {{ .telegramEnabled }};
|
||||||
window.telegramRequired = {{ .telegramRequired }};
|
window.telegramRequired = {{ .telegramRequired }};
|
||||||
window.telegramPIN = "{{ .telegramPIN }}";
|
window.telegramPIN = "{{ .telegramPIN }}";
|
||||||
|
window.emailRequired = {{ .emailRequired }};
|
||||||
window.discordEnabled = {{ .discordEnabled }};
|
window.discordEnabled = {{ .discordEnabled }};
|
||||||
window.discordRequired = {{ .discordRequired }};
|
window.discordRequired = {{ .discordRequired }};
|
||||||
window.discordPIN = "{{ .discordPIN }}";
|
window.discordPIN = "{{ .discordPIN }}";
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
"errorMatrixVerification": "Matrix verification required.",
|
"errorMatrixVerification": "Matrix verification required.",
|
||||||
"errorInvalidPIN": "PIN is invalid.",
|
"errorInvalidPIN": "PIN is invalid.",
|
||||||
"errorUnknown": "Unknown error.",
|
"errorUnknown": "Unknown error.",
|
||||||
|
"errorNoEmail": "Email required.",
|
||||||
"verified": "Account verified."
|
"verified": "Account verified."
|
||||||
},
|
},
|
||||||
"validationStrings": {
|
"validationStrings": {
|
||||||
|
16
ts/form.ts
16
ts/form.ts
@ -29,6 +29,7 @@ interface formWindow extends Window {
|
|||||||
userExpiryHours: number;
|
userExpiryHours: number;
|
||||||
userExpiryMinutes: number;
|
userExpiryMinutes: number;
|
||||||
userExpiryMessage: string;
|
userExpiryMessage: string;
|
||||||
|
emailRequired: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadLangSelector("form");
|
loadLangSelector("form");
|
||||||
@ -39,6 +40,7 @@ window.animationEvent = whichAnimationEvent();
|
|||||||
|
|
||||||
window.successModal = new Modal(document.getElementById("modal-success"), true);
|
window.successModal = new Modal(document.getElementById("modal-success"), true);
|
||||||
|
|
||||||
|
|
||||||
var telegramVerified = false;
|
var telegramVerified = false;
|
||||||
if (window.telegramEnabled) {
|
if (window.telegramEnabled) {
|
||||||
window.telegramModal = new Modal(document.getElementById("modal-telegram"), window.telegramRequired);
|
window.telegramModal = new Modal(document.getElementById("modal-telegram"), window.telegramRequired);
|
||||||
@ -230,6 +232,18 @@ if (!window.usernameEnabled) { usernameField.parentElement.remove(); usernameFie
|
|||||||
const passwordField = document.getElementById("create-password") as HTMLInputElement;
|
const passwordField = document.getElementById("create-password") as HTMLInputElement;
|
||||||
const rePasswordField = document.getElementById("create-reenter-password") as HTMLInputElement;
|
const rePasswordField = document.getElementById("create-reenter-password") as HTMLInputElement;
|
||||||
|
|
||||||
|
if (window.emailRequired) {
|
||||||
|
emailField.addEventListener("keyup", () => {
|
||||||
|
if (emailField.value.includes("@")) {
|
||||||
|
submitButton.disabled = false;
|
||||||
|
submitSpan.removeAttribute("disabled");
|
||||||
|
} else {
|
||||||
|
submitButton.disabled = true;
|
||||||
|
submitSpan.setAttribute("disabled", "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var requirements = initValidator(passwordField, rePasswordField, submitButton, submitSpan)
|
var requirements = initValidator(passwordField, rePasswordField, submitButton, submitSpan)
|
||||||
|
|
||||||
interface respDTO {
|
interface respDTO {
|
||||||
@ -302,7 +316,7 @@ const create = (event: SubmitEvent) => {
|
|||||||
}, true, (req: XMLHttpRequest) => {
|
}, true, (req: XMLHttpRequest) => {
|
||||||
if (req.readyState == 4) {
|
if (req.readyState == 4) {
|
||||||
toggleLoader(submitSpan);
|
toggleLoader(submitSpan);
|
||||||
if (req.status == 401) {
|
if (req.status == 401 || req.status == 400) {
|
||||||
if (req.response["error"] as string) {
|
if (req.response["error"] as string) {
|
||||||
if (req.response["error"] == "confirmEmail") {
|
if (req.response["error"] == "confirmEmail") {
|
||||||
window.confirmationModal.show();
|
window.confirmationModal.show();
|
||||||
|
1
views.go
1
views.go
@ -358,6 +358,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
|||||||
"telegramEnabled": telegram,
|
"telegramEnabled": telegram,
|
||||||
"discordEnabled": discord,
|
"discordEnabled": discord,
|
||||||
"matrixEnabled": matrix,
|
"matrixEnabled": matrix,
|
||||||
|
"emailRequired": app.config.Section("email").Key("required").MustBool(false),
|
||||||
}
|
}
|
||||||
if telegram {
|
if telegram {
|
||||||
data["telegramPIN"] = app.telegram.NewAuthToken()
|
data["telegramPIN"] = app.telegram.NewAuthToken()
|
||||||
|
Loading…
Reference in New Issue
Block a user