mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
form: fix captcha, matrix, telegram
new issue though: discord/telegram/matrix aren't linked when email confirmation is used!
This commit is contained in:
parent
e4a7172517
commit
ebacfd43be
@ -121,7 +121,7 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
discordUser, discordVerified = app.discord.verifiedTokens[req.DiscordPIN]
|
discordUser, discordVerified = app.discord.UserVerified(req.DiscordPIN)
|
||||||
if !discordVerified {
|
if !discordVerified {
|
||||||
f = func(gc *gin.Context) {
|
f = func(gc *gin.Context) {
|
||||||
app.debug.Printf("%s: New user failed: Discord PIN was invalid", req.Code)
|
app.debug.Printf("%s: New user failed: Discord PIN was invalid", req.Code)
|
||||||
@ -207,7 +207,7 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tgToken, telegramVerified = app.telegram.TokenVerified(req.TelegramPIN)
|
tgToken, telegramVerified = app.telegram.TokenVerified(req.TelegramPIN)
|
||||||
if telegramVerified {
|
if !telegramVerified {
|
||||||
f = func(gc *gin.Context) {
|
f = func(gc *gin.Context) {
|
||||||
app.debug.Printf("%s: New user failed: Telegram PIN was invalid", req.Code)
|
app.debug.Printf("%s: New user failed: Telegram PIN was invalid", req.Code)
|
||||||
respond(401, "errorInvalidPIN", gc)
|
respond(401, "errorInvalidPIN", gc)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="{{ .cssClass }}">
|
<html lang="en" class="{{ .cssClass }}">
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" type="text/css" href="css/{{ .cssVersion }}bundle.css">
|
<link rel="stylesheet" type="text/css" href="{{ .urlBase }}/css/{{ .cssVersion }}bundle.css">
|
||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
<title>{{ .strings.successHeader }} - jfa-go</title>
|
<title>{{ .strings.successHeader }} - jfa-go</title>
|
||||||
</head>
|
</head>
|
||||||
|
@ -236,7 +236,7 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
|||||||
user.GET(p+"/discord/verified/:pin", app.MyDiscordVerifiedInvite)
|
user.GET(p+"/discord/verified/:pin", app.MyDiscordVerifiedInvite)
|
||||||
user.GET(p+"/telegram/verified/:pin", app.MyTelegramVerifiedInvite)
|
user.GET(p+"/telegram/verified/:pin", app.MyTelegramVerifiedInvite)
|
||||||
user.POST(p+"/matrix/user", app.MatrixSendMyPIN)
|
user.POST(p+"/matrix/user", app.MatrixSendMyPIN)
|
||||||
user.POST(p+"/matrix/verified/:userID/:pin", app.MatrixCheckMyPIN)
|
user.GET(p+"/matrix/verified/:userID/:pin", app.MatrixCheckMyPIN)
|
||||||
user.DELETE(p+"/discord", app.UnlinkMyDiscord)
|
user.DELETE(p+"/discord", app.UnlinkMyDiscord)
|
||||||
user.DELETE(p+"/telegram", app.UnlinkMyTelegram)
|
user.DELETE(p+"/telegram", app.UnlinkMyTelegram)
|
||||||
user.DELETE(p+"/matrix", app.UnlinkMyMatrix)
|
user.DELETE(p+"/matrix", app.UnlinkMyMatrix)
|
||||||
|
63
ts/form.ts
63
ts/form.ts
@ -176,33 +176,31 @@ let captchaInput = document.getElementById("captcha-input") as HTMLInputElement;
|
|||||||
const captchaCheckbox = document.getElementById("captcha-success") as HTMLSpanElement;
|
const captchaCheckbox = document.getElementById("captcha-success") as HTMLSpanElement;
|
||||||
let prevCaptcha = "";
|
let prevCaptcha = "";
|
||||||
|
|
||||||
function baseValidator(oncomplete: (valid: boolean) => void): void {
|
let baseValidator = (oncomplete: (valid: boolean) => void): void => {
|
||||||
let captchaChecked = false;
|
if (window.captcha && !window.reCAPTCHA && (captchaInput.value != prevCaptcha)) {
|
||||||
let captchaChange = false;
|
prevCaptcha = captchaInput.value;
|
||||||
if (window.captcha && !window.reCAPTCHA) {
|
_post("/captcha/verify/" + window.code + "/" + captchaID + "/" + captchaInput.value, null, (req: XMLHttpRequest) => {
|
||||||
captchaChange = captchaInput.value != prevCaptcha;
|
if (req.readyState == 4) {
|
||||||
if (captchaChange) {
|
if (req.status == 204) {
|
||||||
prevCaptcha = captchaInput.value;
|
captchaCheckbox.innerHTML = `<i class="ri-check-line"></i>`;
|
||||||
_post("/captcha/verify/" + window.code + "/" + captchaID + "/" + captchaInput.value, null, (req: XMLHttpRequest) => {
|
captchaCheckbox.classList.add("~positive");
|
||||||
if (req.readyState == 4) {
|
captchaCheckbox.classList.remove("~critical");
|
||||||
if (req.status == 204) {
|
captchaVerified = true;
|
||||||
captchaCheckbox.innerHTML = `<i class="ri-check-line"></i>`;
|
} else {
|
||||||
captchaCheckbox.classList.add("~positive");
|
captchaCheckbox.innerHTML = `<i class="ri-close-line"></i>`;
|
||||||
captchaCheckbox.classList.remove("~critical");
|
captchaCheckbox.classList.add("~critical");
|
||||||
captchaVerified = true;
|
captchaCheckbox.classList.remove("~positive");
|
||||||
captchaChecked = true;
|
captchaVerified = false;
|
||||||
} else {
|
|
||||||
captchaCheckbox.innerHTML = `<i class="ri-close-line"></i>`;
|
|
||||||
captchaCheckbox.classList.add("~critical");
|
|
||||||
captchaCheckbox.classList.remove("~positive");
|
|
||||||
captchaVerified = false;
|
|
||||||
captchaChecked = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
_baseValidator(oncomplete, captchaVerified);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_baseValidator(oncomplete, captchaVerified);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _baseValidator(oncomplete: (valid: boolean) => void, captchaValid: boolean): void {
|
||||||
if (window.emailRequired) {
|
if (window.emailRequired) {
|
||||||
if (!emailField.value.includes("@")) {
|
if (!emailField.value.includes("@")) {
|
||||||
oncomplete(false);
|
oncomplete(false);
|
||||||
@ -221,18 +219,11 @@ function baseValidator(oncomplete: (valid: boolean) => void): void {
|
|||||||
oncomplete(false);
|
oncomplete(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.captcha && !window.reCAPTCHA) {
|
if (window.captcha && !window.reCAPTCHA && !captchaValid) {
|
||||||
if (!captchaChange) {
|
oncomplete(false);
|
||||||
oncomplete(captchaVerified);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (!captchaChecked) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
oncomplete(captchaVerified);
|
|
||||||
} else {
|
|
||||||
oncomplete(true);
|
|
||||||
}
|
}
|
||||||
|
oncomplete(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GreCAPTCHA {
|
interface GreCAPTCHA {
|
||||||
|
@ -243,7 +243,7 @@ export class Matrix {
|
|||||||
this._input.value = "";
|
this._input.value = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
private _verifyCode = () => _post(this._conf.verifiedURL + this._userID + "/" + this._input.value, null, (req: XMLHttpRequest) => {
|
private _verifyCode = () => _get(this._conf.verifiedURL + this._userID + "/" + this._input.value, null, (req: XMLHttpRequest) => {
|
||||||
if (req.readyState != 4) return;
|
if (req.readyState != 4) return;
|
||||||
removeLoader(this._submit);
|
removeLoader(this._submit);
|
||||||
const valid = req.response["success"] as boolean;
|
const valid = req.response["success"] as boolean;
|
||||||
@ -264,6 +264,6 @@ export class Matrix {
|
|||||||
this._submit.classList.remove("~critical");
|
this._submit.classList.remove("~critical");
|
||||||
}, 800);
|
}, 800);
|
||||||
}
|
}
|
||||||
}, true);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user