commit 4ee6ee01cc8489225cf83b3abcc3d4a634adf3db
parent f919f271bb82e62c3baf63869155d6294d8070c2
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 6 Jun 2023 21:07:30 -0700
cleanup
Diffstat:
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -329,19 +329,19 @@ func loginFormHandler(c echo.Context) error {
return c.Render(http.StatusOK, "standalone.login", data)
}
- if user.GpgTwoFactorEnabled {
+ if user.GpgTwoFactorEnabled || string(user.TwoFactorSecret) != "" {
token := utils.GenerateToken32()
- if user.GpgTwoFactorMode {
- partialAuthCache.SetD(token, NewPartialAuthItem(user.ID, PgpSignStep, sessionDuration))
- return SessionsGpgSignTwoFactorHandler(c, true, token)
+ twoFactorType := PgpStep
+ twoFactorClb := SessionsGpgTwoFactorHandler
+ if user.GpgTwoFactorEnabled && user.GpgTwoFactorMode {
+ twoFactorType = PgpSignStep
+ twoFactorClb = SessionsGpgSignTwoFactorHandler
+ } else if string(user.TwoFactorSecret) != "" {
+ twoFactorType = TwoFactorStep
+ twoFactorClb = SessionsTwoFactorHandler
}
- partialAuthCache.SetD(token, NewPartialAuthItem(user.ID, PgpStep, sessionDuration))
- return SessionsGpgTwoFactorHandler(c, true, token)
-
- } else if string(user.TwoFactorSecret) != "" {
- token := utils.GenerateToken32()
- partialAuthCache.SetD(token, NewPartialAuthItem(user.ID, TwoFactorStep, sessionDuration))
- return SessionsTwoFactorHandler(c, true, token)
+ partialAuthCache.SetD(token, NewPartialAuthItem(user.ID, twoFactorType, sessionDuration))
+ return twoFactorClb(c, true, token)
}
return completeLogin(c, user, sessionDuration)