Finished CAPTCHA
This commit is contained in:
parent
b43d48d997
commit
469bd13b58
4
main.go
4
main.go
|
@ -365,7 +365,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
session.Set("captcha", data.Text)
|
session.Set("captcha", data.Text)
|
||||||
session.Set("id", sessionid)
|
session.Set("unique_token", sessionid)
|
||||||
err = session.Save()
|
err = session.Save()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("[ERROR] Failed to save session in /login at", strconv.FormatInt(time.Now().Unix(), 10)+":", err)
|
fmt.Println("[ERROR] Failed to save session in /login at", strconv.FormatInt(time.Now().Unix(), 10)+":", err)
|
||||||
|
@ -449,8 +449,6 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if data["captcha"].(string) != session.Get("captcha") {
|
if data["captcha"].(string) != session.Get("captcha") {
|
||||||
fmt.Println(data["captcha"])
|
|
||||||
fmt.Println(session.Get("captcha"))
|
|
||||||
c.JSON(401, gin.H{"error": "Captcha failed"})
|
c.JSON(401, gin.H{"error": "Captcha failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,12 +102,14 @@ signupButton.addEventListener("click", () => {
|
||||||
localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password))
|
localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password))
|
||||||
|
|
||||||
window.location.href = "/app" + window.location.search
|
window.location.href = "/app" + window.location.search
|
||||||
}
|
} else if (response.status === 409) {
|
||||||
else if (response.status === 409) {
|
|
||||||
statusBox.innerText = "Username already taken!"
|
statusBox.innerText = "Username already taken!"
|
||||||
showElements(true)
|
showElements(true)
|
||||||
}
|
} else if (response.status === 401) {
|
||||||
else {
|
statusBox.innerText = "CAPTCHA has expired!"
|
||||||
|
} else if (response.status === 403) {
|
||||||
|
statusBox.innerText = "CAPTCHA is incorrect!"
|
||||||
|
} else {
|
||||||
statusBox.innerText = "Something went wrong!"
|
statusBox.innerText = "Something went wrong!"
|
||||||
showElements(true)
|
showElements(true)
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue