aboutsummaryrefslogtreecommitdiff
path: root/internal/route/user/auth.go
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2022-10-24 23:45:31 +0800
committerGitHub <noreply@github.com>2022-10-24 23:45:31 +0800
commit131be6e074039e590488892d7a99ebdbe6eb4668 (patch)
tree391833ed53f439aa469af080591e372b79067b65 /internal/route/user/auth.go
parent49be63abbfc4290b281e05493a0f65bb710c2ade (diff)
refactor(db): migrate helpers off `user_cache.go` (#7214)
Diffstat (limited to 'internal/route/user/auth.go')
-rw-r--r--internal/route/user/auth.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/route/user/auth.go b/internal/route/user/auth.go
index a893f8b5..cf6fa5e3 100644
--- a/internal/route/user/auth.go
+++ b/internal/route/user/auth.go
@@ -235,12 +235,12 @@ func LoginTwoFactorPost(c *context.Context) {
}
// Prevent same passcode from being reused
- if c.Cache.IsExist(u.TwoFactorCacheKey(passcode)) {
+ if c.Cache.IsExist(userutil.TwoFactorCacheKey(u.ID, passcode)) {
c.Flash.Error(c.Tr("settings.two_factor_reused_passcode"))
c.RedirectSubpath("/user/login/two_factor")
return
}
- if err = c.Cache.Put(u.TwoFactorCacheKey(passcode), 1, 60); err != nil {
+ if err = c.Cache.Put(userutil.TwoFactorCacheKey(u.ID, passcode), 1, 60); err != nil {
log.Error("Failed to put cache 'two factor passcode': %v", err)
}
@@ -374,7 +374,7 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60
c.Success(ACTIVATE)
- if err := c.Cache.Put(u.MailResendCacheKey(), 1, 180); err != nil {
+ if err := c.Cache.Put(userutil.MailResendCacheKey(u.ID), 1, 180); err != nil {
log.Error("Failed to put cache key 'mail resend': %v", err)
}
return
@@ -393,13 +393,13 @@ func Activate(c *context.Context) {
}
// Resend confirmation email.
if conf.Auth.RequireEmailConfirmation {
- if c.Cache.IsExist(c.User.MailResendCacheKey()) {
+ if c.Cache.IsExist(userutil.MailResendCacheKey(c.User.ID)) {
c.Data["ResendLimited"] = true
} else {
c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60
email.SendActivateAccountMail(c.Context, db.NewMailerUser(c.User))
- if err := c.Cache.Put(c.User.MailResendCacheKey(), 1, 180); err != nil {
+ if err := c.Cache.Put(userutil.MailResendCacheKey(c.User.ID), 1, 180); err != nil {
log.Error("Failed to put cache key 'mail resend': %v", err)
}
}
@@ -496,14 +496,14 @@ func ForgotPasswdPost(c *context.Context) {
return
}
- if c.Cache.IsExist(u.MailResendCacheKey()) {
+ if c.Cache.IsExist(userutil.MailResendCacheKey(u.ID)) {
c.Data["ResendLimited"] = true
c.Success(FORGOT_PASSWORD)
return
}
email.SendResetPasswordMail(c.Context, db.NewMailerUser(u))
- if err = c.Cache.Put(u.MailResendCacheKey(), 1, 180); err != nil {
+ if err = c.Cache.Put(userutil.MailResendCacheKey(u.ID), 1, 180); err != nil {
log.Error("Failed to put cache key 'mail resend': %v", err)
}