Finished CAPTCHA

This commit is contained in:
Tracker-Friendly 2024-05-09 16:33:01 +01:00
parent b43d48d997
commit 469bd13b58
2 changed files with 7 additions and 7 deletions

View File

@ -365,7 +365,7 @@ func main() {
return
}
session.Set("captcha", data.Text)
session.Set("id", sessionid)
session.Set("unique_token", sessionid)
err = session.Save()
if err != nil {
fmt.Println("[ERROR] Failed to save session in /login at", strconv.FormatInt(time.Now().Unix(), 10)+":", err)
@ -449,8 +449,6 @@ func main() {
return
}
if data["captcha"].(string) != session.Get("captcha") {
fmt.Println(data["captcha"])
fmt.Println(session.Get("captcha"))
c.JSON(401, gin.H{"error": "Captcha failed"})
return
}

View File

@ -102,12 +102,14 @@ signupButton.addEventListener("click", () => {
localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password))
window.location.href = "/app" + window.location.search
}
else if (response.status === 409) {
} else if (response.status === 409) {
statusBox.innerText = "Username already taken!"
showElements(true)
}
else {
} else if (response.status === 401) {
statusBox.innerText = "CAPTCHA has expired!"
} else if (response.status === 403) {
statusBox.innerText = "CAPTCHA is incorrect!"
} else {
statusBox.innerText = "Something went wrong!"
showElements(true)
}