Finished CAPTCHA
This commit is contained in:
parent
b43d48d997
commit
469bd13b58
4
main.go
4
main.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Reference in New Issue