|
|
@ -17,6 +17,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/base" |
|
|
|
"code.gitea.io/gitea/modules/base" |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/recaptcha" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/modules/util" |
|
|
|
"code.gitea.io/gitea/modules/util" |
|
|
|
|
|
|
|
|
|
|
@ -641,6 +642,8 @@ func LinkAccount(ctx *context.Context) { |
|
|
|
ctx.Data["Title"] = ctx.Tr("link_account") |
|
|
|
ctx.Data["Title"] = ctx.Tr("link_account") |
|
|
|
ctx.Data["LinkAccountMode"] = true |
|
|
|
ctx.Data["LinkAccountMode"] = true |
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
|
|
|
|
ctx.Data["CaptchaType"] = setting.Service.CaptchaType |
|
|
|
|
|
|
|
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey |
|
|
|
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration |
|
|
|
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration |
|
|
|
ctx.Data["ShowRegistrationButton"] = false |
|
|
|
ctx.Data["ShowRegistrationButton"] = false |
|
|
|
|
|
|
|
|
|
|
@ -666,6 +669,8 @@ func LinkAccountPostSignIn(ctx *context.Context, signInForm auth.SignInForm) { |
|
|
|
ctx.Data["LinkAccountMode"] = true |
|
|
|
ctx.Data["LinkAccountMode"] = true |
|
|
|
ctx.Data["LinkAccountModeSignIn"] = true |
|
|
|
ctx.Data["LinkAccountModeSignIn"] = true |
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
|
|
|
|
ctx.Data["CaptchaType"] = setting.Service.CaptchaType |
|
|
|
|
|
|
|
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey |
|
|
|
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration |
|
|
|
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration |
|
|
|
ctx.Data["ShowRegistrationButton"] = false |
|
|
|
ctx.Data["ShowRegistrationButton"] = false |
|
|
|
|
|
|
|
|
|
|
@ -732,6 +737,8 @@ func LinkAccountPostRegister(ctx *context.Context, cpt *captcha.Captcha, form au |
|
|
|
ctx.Data["LinkAccountMode"] = true |
|
|
|
ctx.Data["LinkAccountMode"] = true |
|
|
|
ctx.Data["LinkAccountModeRegister"] = true |
|
|
|
ctx.Data["LinkAccountModeRegister"] = true |
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
|
|
|
|
ctx.Data["CaptchaType"] = setting.Service.CaptchaType |
|
|
|
|
|
|
|
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey |
|
|
|
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration |
|
|
|
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration |
|
|
|
ctx.Data["ShowRegistrationButton"] = false |
|
|
|
ctx.Data["ShowRegistrationButton"] = false |
|
|
|
|
|
|
|
|
|
|
@ -755,12 +762,21 @@ func LinkAccountPostRegister(ctx *context.Context, cpt *captcha.Captcha, form au |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if setting.Service.EnableCaptcha && !cpt.VerifyReq(ctx.Req) { |
|
|
|
if setting.Service.EnableCaptcha && setting.Service.CaptchaType == setting.ImageCaptcha && !cpt.VerifyReq(ctx.Req) { |
|
|
|
ctx.Data["Err_Captcha"] = true |
|
|
|
ctx.Data["Err_Captcha"] = true |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplLinkAccount, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplLinkAccount, &form) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if setting.Service.EnableCaptcha && setting.Service.CaptchaType == setting.ReCaptcha { |
|
|
|
|
|
|
|
valid, _ := recaptcha.Verify(form.GRecaptchaResponse) |
|
|
|
|
|
|
|
if !valid { |
|
|
|
|
|
|
|
ctx.Data["Err_Captcha"] = true |
|
|
|
|
|
|
|
ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplLinkAccount, &form) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (len(strings.TrimSpace(form.Password)) > 0 || len(strings.TrimSpace(form.Retype)) > 0) && form.Password != form.Retype { |
|
|
|
if (len(strings.TrimSpace(form.Password)) > 0 || len(strings.TrimSpace(form.Retype)) > 0) && form.Password != form.Retype { |
|
|
|
ctx.Data["Err_Password"] = true |
|
|
|
ctx.Data["Err_Password"] = true |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplLinkAccount, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplLinkAccount, &form) |
|
|
@ -858,6 +874,9 @@ func SignUp(ctx *context.Context) { |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["CaptchaType"] = setting.Service.CaptchaType |
|
|
|
|
|
|
|
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration |
|
|
|
ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration |
|
|
|
|
|
|
|
|
|
|
|
ctx.HTML(200, tplSignUp) |
|
|
|
ctx.HTML(200, tplSignUp) |
|
|
@ -871,6 +890,9 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["CaptchaType"] = setting.Service.CaptchaType |
|
|
|
|
|
|
|
ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey |
|
|
|
|
|
|
|
|
|
|
|
//Permission denied if DisableRegistration or AllowOnlyExternalRegistration options are true
|
|
|
|
//Permission denied if DisableRegistration or AllowOnlyExternalRegistration options are true
|
|
|
|
if !setting.Service.ShowRegistrationButton { |
|
|
|
if !setting.Service.ShowRegistrationButton { |
|
|
|
ctx.Error(403) |
|
|
|
ctx.Error(403) |
|
|
@ -882,12 +904,21 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if setting.Service.EnableCaptcha && !cpt.VerifyReq(ctx.Req) { |
|
|
|
if setting.Service.EnableCaptcha && setting.Service.CaptchaType == setting.ImageCaptcha && !cpt.VerifyReq(ctx.Req) { |
|
|
|
ctx.Data["Err_Captcha"] = true |
|
|
|
ctx.Data["Err_Captcha"] = true |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplSignUp, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplSignUp, &form) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if setting.Service.EnableCaptcha && setting.Service.CaptchaType == setting.ReCaptcha { |
|
|
|
|
|
|
|
valid, _ := recaptcha.Verify(form.GRecaptchaResponse) |
|
|
|
|
|
|
|
if !valid { |
|
|
|
|
|
|
|
ctx.Data["Err_Captcha"] = true |
|
|
|
|
|
|
|
ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplSignUp, &form) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if form.Password != form.Retype { |
|
|
|
if form.Password != form.Retype { |
|
|
|
ctx.Data["Err_Password"] = true |
|
|
|
ctx.Data["Err_Password"] = true |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplSignUp, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplSignUp, &form) |
|
|
|