diff options
author | Joe Chen <jc@unknwon.io> | 2022-06-11 11:54:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-11 11:54:11 +0800 |
commit | 5e32058c13f34b46c69b7cdee6ccc0b7fe3b6df3 (patch) | |
tree | 92353ba2d8b6461754b89e95f581f4d402cf42af /internal/route/user | |
parent | 75fbb8244086a2ad964d1c51e3bdbdfb95df90ac (diff) |
db: use `context` and go-mockgen for `TwoFactorsStore` (#7045)
Diffstat (limited to 'internal/route/user')
-rw-r--r-- | internal/route/user/auth.go | 2 | ||||
-rw-r--r-- | internal/route/user/setting.go | 4 |
2 files changed, 3 insertions, 3 deletions
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 |