commit 59435ea5abccc88338d1f1732f93305fff5afde0
parent 79a9bdf122f5fb711b5c0d6f0fdac3bab8444d53
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sun, 18 Dec 2022 12:50:08 -0800
refactor
Diffstat:
4 files changed, 90 insertions(+), 90 deletions(-)
diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go
@@ -63,9 +63,9 @@ type sessionsTwoFactorRecoveryData struct {
}
type waitData struct {
- WaitTime int64
- Frames []string
- SignupToken string
+ WaitTime int64
+ Frames []string
+ WaitToken string
}
type signupData struct {
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -774,14 +774,14 @@ type WaitPageCookiePayload struct {
func waitPageWrapper(c echo.Context, clb echo.HandlerFunc, cookieName string) error {
start := time.Now().UnixNano()
- var signupToken string
+ var waitToken string
if cc, payload, err := hutils.EncCookie[WaitPageCookiePayload](c, cookieName); err != nil {
// No cookie found, we create one and display the waiting page.
waitTime := utils.Random(5, 15)
- signupToken = utils.GenerateToken10()
+ waitToken = utils.GenerateToken10()
payload := WaitPageCookiePayload{
- Token: signupToken,
+ Token: waitToken,
Count: 1,
Now: time.Now().UnixMilli(),
Unix: time.Now().Unix() + waitTime - 1, // unix time at which the wait time is over
@@ -792,12 +792,12 @@ func waitPageWrapper(c echo.Context, clb echo.HandlerFunc, cookieName string) er
// Generate css frames
data.Frames = generateCssFrames(waitTime, nil, true)
data.WaitTime = waitTime
- data.SignupToken = signupToken
- return c.Render(http.StatusOK, "signup-wait", data)
+ data.WaitToken = waitToken
+ return c.Render(http.StatusOK, "wait", data)
} else {
// Cookie was found, incr counter then call callback
- signupToken = payload.Token
+ waitToken = payload.Token
start = payload.Now
if c.Request().Method == http.MethodGet {
// If you reload the page before the wait time is over, we kill the circuit.
@@ -820,7 +820,7 @@ func waitPageWrapper(c echo.Context, clb echo.HandlerFunc, cookieName string) er
}
}
c.Set("start", start)
- c.Set("signupToken", signupToken)
+ c.Set("signupToken", waitToken)
return clb(c)
}
diff --git a/pkg/web/public/views/pages/signup-wait.gohtml b/pkg/web/public/views/pages/signup-wait.gohtml
@@ -1,79 +0,0 @@
-{{ define "base" }}<!DOCTYPE html><html lang="en"><head>
- {{ .LogoASCII }}
- {{ .VersionHTML }}
- {{ .ShaHTML }}
- <link href="/public/img/favicon.ico" rel="icon" type="image/x-icon" />
- <meta charset="UTF-8" />
- <meta name="author" content="n0tr1v">
- <meta name="keywords" content="{{ block "keywords" . }}{{ .BaseKeywords }}{{ end }}"/>
- <meta name="subject" content="">
- <meta name="description" content="{{ block "meta-description" . }}{{ end }}" />
- <meta name="classification" content="">
- <meta name="distribution" content="">
- <meta name="robots" content="all" />
- <meta name="language" content="English">
- <meta name="revisit-after" content="1 days">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="pragma" content="no-cache">
- <title>{{ block "title" . }}DarkForest{{ end }}</title>
- {{ block "canonical-link" . }}{{ end }}
- <link rel="stylesheet" type="text/css" href="/public/css/bootstrap.min.css?v={{ .VERSION }}" />
- <link rel="stylesheet" type="text/css" href="/public/css/style.css?v={{ .VERSION }}" />
- <link rel="stylesheet" type="text/css" href="/public/css/{{ .Data.SignupToken }}/signup.css?v={{ .VERSION }}" />
- <meta http-equiv="refresh" content="{{ .Data.WaitTime }}">
-
- <style>
- body, html {
- height: 100%;
- display:table;
- width:100%;
- }
- body {
- display:table-cell;
- vertical-align:middle;
- }
- .bg {
- /* The image used */
- background-image: url({{ .WallpaperImg }});
-
- /* Full height */
- height: 100%;
-
- /* Center and scale the image nicely */
- background-position: center;
- background-repeat: no-repeat;
- background-size: cover;
- }
- #parent {
- display: table;
- width: 100%;
- }
- #form_login {
- display:table;/* shrinks to fit content */
- margin:auto;
- }
- #timer_countdown:before {
- content: "{{ .Data.WaitTime }}";
- animation: {{ .Data.WaitTime }}s 1s forwards timer_countdown_frames;
- }
- @keyframes timer_countdown_frames {
- {{ range .Data.Frames -}}{{ . | css }}{{ end -}}
- }
- </style>
-</head>
-<body class="bg">
-
-<div id="parent">
- <div class="container" id="form_login">
- <div class="row">
- <div class="col-8 offset-2 col-md-8 offset-md-2 col-sm-8 col-lg-6 offset-lg-3 col-xl-4 offset-xl-4">
- <div class="bg-label">Please wait <span id="timer_countdown"></span> seconds to be automatically redirected</div>
- </div>
- </div>
- </div>
-</div>
-<div class="div_1"></div>
-<div class="div_2"></div>
-<div class="div_f0">a</div>
-</body>
-</html>{{ end }}
-\ No newline at end of file
diff --git a/pkg/web/public/views/pages/wait.gohtml b/pkg/web/public/views/pages/wait.gohtml
@@ -0,0 +1,79 @@
+{{ define "base" }}<!DOCTYPE html><html lang="en"><head>
+ {{ .LogoASCII }}
+ {{ .VersionHTML }}
+ {{ .ShaHTML }}
+ <link href="/public/img/favicon.ico" rel="icon" type="image/x-icon" />
+ <meta charset="UTF-8" />
+ <meta name="author" content="n0tr1v">
+ <meta name="keywords" content="{{ block "keywords" . }}{{ .BaseKeywords }}{{ end }}"/>
+ <meta name="subject" content="">
+ <meta name="description" content="{{ block "meta-description" . }}{{ end }}" />
+ <meta name="classification" content="">
+ <meta name="distribution" content="">
+ <meta name="robots" content="all" />
+ <meta name="language" content="English">
+ <meta name="revisit-after" content="1 days">
+ <meta http-equiv="expires" content="0">
+ <meta http-equiv="pragma" content="no-cache">
+ <title>{{ block "title" . }}DarkForest{{ end }}</title>
+ {{ block "canonical-link" . }}{{ end }}
+ <link rel="stylesheet" type="text/css" href="/public/css/bootstrap.min.css?v={{ .VERSION }}" />
+ <link rel="stylesheet" type="text/css" href="/public/css/style.css?v={{ .VERSION }}" />
+ <link rel="stylesheet" type="text/css" href="/public/css/{{ .Data.WaitToken }}/signup.css?v={{ .VERSION }}" />
+ <meta http-equiv="refresh" content="{{ .Data.WaitTime }}">
+
+ <style>
+ body, html {
+ height: 100%;
+ display:table;
+ width:100%;
+ }
+ body {
+ display:table-cell;
+ vertical-align:middle;
+ }
+ .bg {
+ /* The image used */
+ background-image: url({{ .WallpaperImg }});
+
+ /* Full height */
+ height: 100%;
+
+ /* Center and scale the image nicely */
+ background-position: center;
+ background-repeat: no-repeat;
+ background-size: cover;
+ }
+ #parent {
+ display: table;
+ width: 100%;
+ }
+ #form_login {
+ display:table;/* shrinks to fit content */
+ margin:auto;
+ }
+ #timer_countdown:before {
+ content: "{{ .Data.WaitTime }}";
+ animation: {{ .Data.WaitTime }}s 1s forwards timer_countdown_frames;
+ }
+ @keyframes timer_countdown_frames {
+ {{ range .Data.Frames -}}{{ . | css }}{{ end -}}
+ }
+ </style>
+</head>
+<body class="bg">
+
+<div id="parent">
+ <div class="container" id="form_login">
+ <div class="row">
+ <div class="col-8 offset-2 col-md-8 offset-md-2 col-sm-8 col-lg-6 offset-lg-3 col-xl-4 offset-xl-4">
+ <div class="bg-label">Please wait <span id="timer_countdown"></span> seconds to be automatically redirected</div>
+ </div>
+ </div>
+ </div>
+</div>
+<div class="div_1"></div>
+<div class="div_2"></div>
+<div class="div_f0">a</div>
+</body>
+</html>{{ end }}
+\ No newline at end of file