From c6ddc7b1975aada5901275882f68a12c1491d7c5 Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Sat, 25 Nov 2023 15:08:44 +0000 Subject: [PATCH] Add otp enabled state on the home --- pages/edit-otp.go.html | 2 +- pages/edit-password.go.html | 28 ++++++++++++++++++++++++++++ pages/edit-username.go.html | 0 pages/index.go.html | 30 +++++++++++++++++------------- pages/login-otp.go.html | 2 +- pages/verification-code.go.html | 26 -------------------------- server/home.go | 6 ++++++ 7 files changed, 53 insertions(+), 41 deletions(-) delete mode 100644 pages/edit-username.go.html delete mode 100644 pages/verification-code.go.html diff --git a/pages/edit-otp.go.html b/pages/edit-otp.go.html index 6b067ac..c812558 100644 --- a/pages/edit-otp.go.html +++ b/pages/edit-otp.go.html @@ -17,7 +17,7 @@

Raw OTP string: {{.OtpUrl}}

- +
diff --git a/pages/edit-password.go.html b/pages/edit-password.go.html index e69de29..99e1cbc 100644 --- a/pages/edit-password.go.html +++ b/pages/edit-password.go.html @@ -0,0 +1,28 @@ + + + + {{.ServiceName}} + + +
+

{{.ServiceName}}

+
+
+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + diff --git a/pages/edit-username.go.html b/pages/edit-username.go.html deleted file mode 100644 index e69de29..0000000 diff --git a/pages/index.go.html b/pages/index.go.html index 737a71e..7852e1b 100644 --- a/pages/index.go.html +++ b/pages/index.go.html @@ -14,11 +14,6 @@ -
-
- -
-
@@ -34,14 +29,23 @@
-
-
- - - - -
-
+ {{if .OtpEnabled}} +
+
+ + +
+
+ {{else}} +
+
+ + + + +
+
+ {{end}}
diff --git a/pages/login-otp.go.html b/pages/login-otp.go.html index 5cc8d28..799c70e 100644 --- a/pages/login-otp.go.html +++ b/pages/login-otp.go.html @@ -12,7 +12,7 @@
- +
diff --git a/pages/verification-code.go.html b/pages/verification-code.go.html deleted file mode 100644 index c8ca642..0000000 --- a/pages/verification-code.go.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - {{.Title}} - - - -
-

{{.Title}}

-

Hi {{.Name}},

-

Here is your email verification code: {{.Code}}

-

{{.ServiceName}}

-
- - diff --git a/server/home.go b/server/home.go index 7ff3be5..362eeee 100644 --- a/server/home.go +++ b/server/home.go @@ -27,11 +27,16 @@ func (h *HttpServer) Home(rw http.ResponseWriter, req *http.Request, _ httproute } var userWithName *database.User + var hasTwoFactor bool if h.DbTx(rw, func(tx *database.Tx) (err error) { userWithName, err = tx.GetUserDisplayName(auth.Data.ID) if err != nil { return fmt.Errorf("failed to get user display name: %w", err) } + hasTwoFactor, err = tx.HasTwoFactor(auth.Data.ID) + if err != nil { + return fmt.Errorf("failed to get user two factor state: %w", err) + } return }) { return @@ -41,5 +46,6 @@ func (h *HttpServer) Home(rw http.ResponseWriter, req *http.Request, _ httproute "Auth": auth, "User": userWithName, "Nonce": lNonce, + "OtpEnabled": hasTwoFactor, }) }