loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: disable forgotten password for external signin only (#6680)

- Make it such that `[service].ENABLE_INTERNAL_SIGNIN = false` disables the forgotten password prompt on the login page.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6680
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: davrot <davrot@noreply.codeberg.org>
Co-committed-by: davrot <davrot@noreply.codeberg.org>

authored by

davrot
davrot
and committed by
Gusted
ef2fbc60 b1a7db7e

+45
+3
routers/web/auth/auth.go
··· 171 171 context.SetCaptchaData(ctx) 172 172 } 173 173 174 + ctx.Data["DisablePassword"] = !setting.Service.EnableInternalSignIn 175 + 174 176 ctx.HTML(http.StatusOK, tplSignIn) 175 177 } 176 178 ··· 190 192 ctx.Data["PageIsLogin"] = true 191 193 ctx.Data["EnableSSPI"] = auth.IsSSPIEnabled(ctx) 192 194 ctx.Data["EnableInternalSignIn"] = setting.Service.EnableInternalSignIn 195 + ctx.Data["DisablePassword"] = !setting.Service.EnableInternalSignIn 193 196 194 197 // Permission denied if EnableInternalSignIn is false 195 198 if !setting.Service.EnableInternalSignIn {
+3
templates/user/auth/signin_inner.tmpl
··· 50 50 </div> 51 51 </div> 52 52 53 + {{if not .DisablePassword}} 53 54 <div class="ui container fluid"> 54 55 {{template "user/auth/webauthn_error" .}} 55 56 ··· 65 66 </div> 66 67 </div> 67 68 </div> 69 + {{end}} 70 +
+39
tests/integration/disable_forgotten_password_test.go
··· 1 + package integration 2 + 3 + import ( 4 + "net/http" 5 + "testing" 6 + 7 + "code.gitea.io/gitea/modules/setting" 8 + "code.gitea.io/gitea/modules/test" 9 + "code.gitea.io/gitea/tests" 10 + ) 11 + 12 + func TestDisableForgottenPasswordFalse(t *testing.T) { 13 + defer tests.PrepareTestEnv(t)() 14 + defer test.MockVariableValue(&setting.Service.EnableInternalSignIn, true)() 15 + 16 + req := NewRequest(t, "GET", "/user/login/") 17 + resp := MakeRequest(t, req, http.StatusOK) 18 + htmlDoc := NewHTMLParser(t, resp.Body) 19 + htmlDoc.AssertElement(t, "a[href='/user/forgot_password']", true) 20 + } 21 + 22 + func TestDisableForgottenPasswordTrue(t *testing.T) { 23 + defer tests.PrepareTestEnv(t)() 24 + defer test.MockVariableValue(&setting.Service.EnableInternalSignIn, false)() 25 + 26 + req := NewRequest(t, "GET", "/user/login/") 27 + resp := MakeRequest(t, req, http.StatusOK) 28 + htmlDoc := NewHTMLParser(t, resp.Body) 29 + htmlDoc.AssertElement(t, "a[href='/user/forgot_password']", false) 30 + } 31 + 32 + func TestDisableForgottenPasswordDefault(t *testing.T) { 33 + defer tests.PrepareTestEnv(t)() 34 + 35 + req := NewRequest(t, "GET", "/user/login/") 36 + resp := MakeRequest(t, req, http.StatusOK) 37 + htmlDoc := NewHTMLParser(t, resp.Body) 38 + htmlDoc.AssertElement(t, "a[href='/user/forgot_password']", true) 39 + }