mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-03-04 08:14:43 +01:00
[v10.0/forgejo] fix: disable forgotten password for external signin only (#6930)
Some checks failed
/ release (push) Has been cancelled
testing / backend-checks (push) Has been cancelled
testing / frontend-checks (push) Has been cancelled
testing / test-unit (push) Has been cancelled
testing / test-e2e (push) Has been cancelled
testing / test-remote-cacher (redis) (push) Has been cancelled
testing / test-remote-cacher (valkey) (push) Has been cancelled
testing / test-remote-cacher (garnet) (push) Has been cancelled
testing / test-remote-cacher (redict) (push) Has been cancelled
testing / test-mysql (push) Has been cancelled
testing / test-pgsql (push) Has been cancelled
testing / test-sqlite (push) Has been cancelled
testing / security-check (push) Has been cancelled
Some checks failed
/ release (push) Has been cancelled
testing / backend-checks (push) Has been cancelled
testing / frontend-checks (push) Has been cancelled
testing / test-unit (push) Has been cancelled
testing / test-e2e (push) Has been cancelled
testing / test-remote-cacher (redis) (push) Has been cancelled
testing / test-remote-cacher (valkey) (push) Has been cancelled
testing / test-remote-cacher (garnet) (push) Has been cancelled
testing / test-remote-cacher (redict) (push) Has been cancelled
testing / test-mysql (push) Has been cancelled
testing / test-pgsql (push) Has been cancelled
testing / test-sqlite (push) Has been cancelled
testing / security-check (push) Has been cancelled
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/6680 - Make it such that `[service].ENABLE_INTERNAL_SIGNIN = false` disables the forgotten password prompt on the login page. Co-authored-by: davrot <davrot@noreply.codeberg.org> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6930 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
parent
4802c33acb
commit
0fe56e6059
3 changed files with 45 additions and 0 deletions
|
@ -170,6 +170,8 @@ func SignIn(ctx *context.Context) {
|
||||||
context.SetCaptchaData(ctx)
|
context.SetCaptchaData(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Data["DisablePassword"] = !setting.Service.EnableInternalSignIn
|
||||||
|
|
||||||
ctx.HTML(http.StatusOK, tplSignIn)
|
ctx.HTML(http.StatusOK, tplSignIn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +191,7 @@ func SignInPost(ctx *context.Context) {
|
||||||
ctx.Data["PageIsLogin"] = true
|
ctx.Data["PageIsLogin"] = true
|
||||||
ctx.Data["EnableSSPI"] = auth.IsSSPIEnabled(ctx)
|
ctx.Data["EnableSSPI"] = auth.IsSSPIEnabled(ctx)
|
||||||
ctx.Data["EnableInternalSignIn"] = setting.Service.EnableInternalSignIn
|
ctx.Data["EnableInternalSignIn"] = setting.Service.EnableInternalSignIn
|
||||||
|
ctx.Data["DisablePassword"] = !setting.Service.EnableInternalSignIn
|
||||||
|
|
||||||
// Permission denied if EnableInternalSignIn is false
|
// Permission denied if EnableInternalSignIn is false
|
||||||
if !setting.Service.EnableInternalSignIn {
|
if !setting.Service.EnableInternalSignIn {
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{if not .DisablePassword}}
|
||||||
<div class="ui container fluid">
|
<div class="ui container fluid">
|
||||||
{{template "user/auth/webauthn_error" .}}
|
{{template "user/auth/webauthn_error" .}}
|
||||||
|
|
||||||
|
@ -65,3 +66,5 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
|
39
tests/integration/disable_forgotten_password_test.go
Normal file
39
tests/integration/disable_forgotten_password_test.go
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package integration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/test"
|
||||||
|
"code.gitea.io/gitea/tests"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDisableForgottenPasswordFalse(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
defer test.MockVariableValue(&setting.Service.EnableInternalSignIn, true)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/user/login/")
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
htmlDoc.AssertElement(t, "a[href='/user/forgot_password']", true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDisableForgottenPasswordTrue(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
defer test.MockVariableValue(&setting.Service.EnableInternalSignIn, false)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/user/login/")
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
htmlDoc.AssertElement(t, "a[href='/user/forgot_password']", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDisableForgottenPasswordDefault(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
req := NewRequest(t, "GET", "/user/login/")
|
||||||
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
htmlDoc.AssertElement(t, "a[href='/user/forgot_password']", true)
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue