commit 9bcdd6d1a486b4181b4cb895192880419d9d2372
parent 5131c7f32acc7afebc0baa3e631ec27a1cc50e0e
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sun, 26 Feb 2023 20:46:20 -0800
cleanup
Diffstat:
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -4113,6 +4113,7 @@ type ByteRoadPayload struct {
func ByteRoadChallengeHandler(c echo.Context) error {
authUser := c.Get("authUser").(*database.User)
+ const byteRoadChallengeTmplName = "vip.byte-road-challenge"
var data byteRoadChallengeData
data.ActiveTab = "home"
@@ -4121,7 +4122,7 @@ func ByteRoadChallengeHandler(c echo.Context) error {
data.NbAccountsRegistered = payload.Count
if payload.Count >= 100 {
data.FlagFound = true
- return c.Render(http.StatusOK, "vip.byte-road-challenge", data)
+ return c.Render(http.StatusOK, byteRoadChallengeTmplName, data)
}
}
@@ -4139,13 +4140,13 @@ func ByteRoadChallengeHandler(c echo.Context) error {
captchaInput := c.Request().PostFormValue("captcha")
if err := hutils.CaptchaVerifyString(c, captchaID, captchaInput); err != nil {
data.ErrCaptcha = err.Error()
- return c.Render(http.StatusOK, "vip.byte-road-challenge", data)
+ return c.Render(http.StatusOK, byteRoadChallengeTmplName, data)
}
token := utils.GenerateToken32()
setCookie(token)
byteRoadSignUpSessionCache.SetD(token, true)
data.CaptchaSolved = true
- return c.Render(http.StatusOK, "vip.byte-road-challenge", data)
+ return c.Render(http.StatusOK, byteRoadChallengeTmplName, data)
} else if formName == "register" {
captchaSession, err := c.Cookie(hutils.ByteRoadCookieName)
@@ -4163,13 +4164,13 @@ func ByteRoadChallengeHandler(c echo.Context) error {
data.CaptchaSolved = true
data.Registered = false
data.ErrRegistration = "Invalid username (3-10 ascii characters)"
- return c.Render(http.StatusOK, "vip.byte-road-challenge", data)
+ return c.Render(http.StatusOK, byteRoadChallengeTmplName, data)
}
if !govalidator.IsASCII(data.Password) || len(data.Password) < 3 || len(data.Password) > 10 {
data.CaptchaSolved = true
data.Registered = false
data.ErrRegistration = "Invalid password (3-10 ascii characters)"
- return c.Render(http.StatusOK, "vip.byte-road-challenge", data)
+ return c.Render(http.StatusOK, byteRoadChallengeTmplName, data)
}
data.Registered = true
@@ -4182,7 +4183,7 @@ func ByteRoadChallengeHandler(c echo.Context) error {
data.CaptchaSolved = true
data.Registered = false
data.ErrRegistration = "Username is already registered"
- return c.Render(http.StatusOK, "vip.byte-road-challenge", data)
+ return c.Render(http.StatusOK, byteRoadChallengeTmplName, data)
}
token := utils.GenerateToken32()
@@ -4194,7 +4195,7 @@ func ByteRoadChallengeHandler(c echo.Context) error {
data.FlagFound = true
_ = database.CreateUserBadge(authUser.ID, 2)
}
- return c.Render(http.StatusOK, "vip.byte-road-challenge", data)
+ return c.Render(http.StatusOK, byteRoadChallengeTmplName, data)
}
token := utils.GenerateToken32()
@@ -4202,11 +4203,11 @@ func ByteRoadChallengeHandler(c echo.Context) error {
payload := ByteRoadPayload{Count: 1, Usernames: map[string]struct{}{data.Username: {}}}
byteRoadUsersCountCache.SetD(authUser.ID, payload)
- return c.Render(http.StatusOK, "vip.byte-road-challenge", data)
+ return c.Render(http.StatusOK, byteRoadChallengeTmplName, data)
}
}
- return c.Render(http.StatusOK, "vip.byte-road-challenge", data)
+ return c.Render(http.StatusOK, byteRoadChallengeTmplName, data)
}
func ForgotPasswordBypassChallengeHandler(c echo.Context) error {