diff options
author | zeripath <art27@cantab.net> | 2021-05-31 07:18:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-31 02:18:11 -0400 |
commit | 3183a465d71a13535e52589bb85b987176872fcd (patch) | |
tree | 03d1cb88627176f35e168cda5e46df197dcc3110 /routers/user | |
parent | 518ed504ef8714eeac126fc59ff57f50a98e3692 (diff) | |
download | gitea-3183a465d71a13535e52589bb85b987176872fcd.tar.gz gitea-3183a465d71a13535e52589bb85b987176872fcd.zip |
Make modules/context.Context a context.Context (#16031)
* Make modules/context.Context a context.Context
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Simplify context calls
Signed-off-by: Andrew Thornton <art27@cantab.net>
* Set the base context for requests to the HammerContext
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers/user')
-rw-r--r-- | routers/user/auth.go | 12 | ||||
-rw-r--r-- | routers/user/auth_openid.go | 4 | ||||
-rw-r--r-- | routers/user/setting/account.go | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/routers/user/auth.go b/routers/user/auth.go index 5f8b1a6b99..827b7cdef0 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -1011,9 +1011,9 @@ func LinkAccountPostRegister(ctx *context.Context) { case setting.ImageCaptcha: valid = context.GetImageCaptcha().VerifyReq(ctx.Req) case setting.ReCaptcha: - valid, err = recaptcha.Verify(ctx.Req.Context(), form.GRecaptchaResponse) + valid, err = recaptcha.Verify(ctx, form.GRecaptchaResponse) case setting.HCaptcha: - valid, err = hcaptcha.Verify(ctx.Req.Context(), form.HcaptchaResponse) + valid, err = hcaptcha.Verify(ctx, form.HcaptchaResponse) default: ctx.ServerError("Unknown Captcha Type", fmt.Errorf("Unknown Captcha Type: %s", setting.Service.CaptchaType)) return @@ -1153,9 +1153,9 @@ func SignUpPost(ctx *context.Context) { case setting.ImageCaptcha: valid = context.GetImageCaptcha().VerifyReq(ctx.Req) case setting.ReCaptcha: - valid, err = recaptcha.Verify(ctx.Req.Context(), form.GRecaptchaResponse) + valid, err = recaptcha.Verify(ctx, form.GRecaptchaResponse) case setting.HCaptcha: - valid, err = hcaptcha.Verify(ctx.Req.Context(), form.HcaptchaResponse) + valid, err = hcaptcha.Verify(ctx, form.HcaptchaResponse) default: ctx.ServerError("Unknown Captcha Type", fmt.Errorf("Unknown Captcha Type: %s", setting.Service.CaptchaType)) return @@ -1191,7 +1191,7 @@ func SignUpPost(ctx *context.Context) { ctx.RenderWithErr(password.BuildComplexityError(ctx), tplSignUp, &form) return } - pwned, err := password.IsPwned(ctx.Req.Context(), form.Password) + pwned, err := password.IsPwned(ctx, form.Password) if pwned { errMsg := ctx.Tr("auth.password_pwned") if err != nil { @@ -1620,7 +1620,7 @@ func ResetPasswdPost(ctx *context.Context) { ctx.Data["Err_Password"] = true ctx.RenderWithErr(password.BuildComplexityError(ctx), tplResetPassword, nil) return - } else if pwned, err := password.IsPwned(ctx.Req.Context(), passwd); pwned || err != nil { + } else if pwned, err := password.IsPwned(ctx, passwd); pwned || err != nil { errMsg := ctx.Tr("auth.password_pwned") if err != nil { log.Error(err.Error()) diff --git a/routers/user/auth_openid.go b/routers/user/auth_openid.go index b1dfc6ada0..1a73a08c48 100644 --- a/routers/user/auth_openid.go +++ b/routers/user/auth_openid.go @@ -385,13 +385,13 @@ func RegisterOpenIDPost(ctx *context.Context) { ctx.ServerError("", err) return } - valid, err = recaptcha.Verify(ctx.Req.Context(), form.GRecaptchaResponse) + valid, err = recaptcha.Verify(ctx, form.GRecaptchaResponse) case setting.HCaptcha: if err := ctx.Req.ParseForm(); err != nil { ctx.ServerError("", err) return } - valid, err = hcaptcha.Verify(ctx.Req.Context(), form.HcaptchaResponse) + valid, err = hcaptcha.Verify(ctx, form.HcaptchaResponse) default: ctx.ServerError("Unknown Captcha Type", fmt.Errorf("Unknown Captcha Type: %s", setting.Service.CaptchaType)) return diff --git a/routers/user/setting/account.go b/routers/user/setting/account.go index e12d63ee02..48ab37d936 100644 --- a/routers/user/setting/account.go +++ b/routers/user/setting/account.go @@ -58,7 +58,7 @@ func AccountPost(ctx *context.Context) { ctx.Flash.Error(ctx.Tr("form.password_not_match")) } else if !password.IsComplexEnough(form.Password) { ctx.Flash.Error(password.BuildComplexityError(ctx)) - } else if pwned, err := password.IsPwned(ctx.Req.Context(), form.Password); pwned || err != nil { + } else if pwned, err := password.IsPwned(ctx, form.Password); pwned || err != nil { errMsg := ctx.Tr("auth.password_pwned") if err != nil { log.Error(err.Error()) |