From 5e32058c13f34b46c69b7cdee6ccc0b7fe3b6df3 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Sat, 11 Jun 2022 11:54:11 +0800 Subject: db: use `context` and go-mockgen for `TwoFactorsStore` (#7045) --- internal/route/user/auth.go | 2 +- internal/route/user/setting.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'internal/route/user') diff --git a/internal/route/user/auth.go b/internal/route/user/auth.go index b3b785c2..cae46853 100644 --- a/internal/route/user/auth.go +++ b/internal/route/user/auth.go @@ -210,7 +210,7 @@ func LoginTwoFactorPost(c *context.Context) { return } - t, err := db.TwoFactors.GetByUserID(userID) + t, err := db.TwoFactors.GetByUserID(c.Req.Context(), userID) if err != nil { c.Error(err, "get two factor by user ID") return diff --git a/internal/route/user/setting.go b/internal/route/user/setting.go index c28a1747..66e3ace2 100644 --- a/internal/route/user/setting.go +++ b/internal/route/user/setting.go @@ -381,7 +381,7 @@ func SettingsSecurity(c *context.Context) { c.Title("settings.security") c.PageIs("SettingsSecurity") - t, err := db.TwoFactors.GetByUserID(c.UserID()) + t, err := db.TwoFactors.GetByUserID(c.Req.Context(), c.UserID()) if err != nil && !db.IsErrTwoFactorNotFound(err) { c.Errorf(err, "get two factor by user ID") return @@ -449,7 +449,7 @@ func SettingsTwoFactorEnablePost(c *context.Context) { return } - if err := db.TwoFactors.Create(c.UserID(), conf.Security.SecretKey, secret); err != nil { + if err := db.TwoFactors.Create(c.Req.Context(), c.UserID(), conf.Security.SecretKey, secret); err != nil { c.Flash.Error(c.Tr("settings.two_factor_enable_error", err)) c.RedirectSubpath("/user/settings/security/two_factor_enable") return -- cgit v1.2.3