1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Allow to disable the password-based login (sign-in) form (#32687)

Usually enterprise/organization users would like to only allow OAuth2
login.

This PR adds a new config option to disable the password-based login
form. It is a simple and clear approach and won't block the future
login-system refactoring works.

Fix a TODO in #24821

Replace  #21851

Close #7633 , close #13606
This commit is contained in:
wxiaoguang
2024-12-02 02:03:15 +08:00
committed by GitHub
parent 1bb1a51f47
commit def13ece7c
7 changed files with 73 additions and 48 deletions

View File

@@ -1,7 +1,3 @@
{{if or .OAuth2Providers .EnableOpenIDSignIn}}
<div class="divider divider-text">
{{ctx.Locale.Tr "sign_in_or"}}
</div>
<div id="oauth2-login-navigator" class="tw-py-1">
<div class="tw-flex tw-flex-col tw-justify-center">
<div id="oauth2-login-navigator-inner" class="tw-flex tw-flex-col tw-flex-wrap tw-items-center tw-gap-2">
@@ -26,4 +22,3 @@
</div>
</div>
</div>
{{end}}

View File

@@ -10,6 +10,7 @@
{{end}}
</h4>
<div class="ui attached segment">
{{if .EnablePasswordSignInForm}}
<form class="ui form" action="{{.SignInLink}}" method="post">
{{.CsrfTokenHtml}}
<div class="required field {{if and (.Err_UserName) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn))}}error{{end}}">
@@ -46,8 +47,13 @@
</button>
</div>
</form>
{{template "user/auth/oauth_container" .}}
{{end}}{{/*if .EnablePasswordSignInForm*/}}
{{if and .OAuth2Providers .EnableOpenIDSignIn .EnablePasswordSignInForm}}
<div class="divider divider-text">{{ctx.Locale.Tr "sign_in_or"}}</div>
{{end}}
{{if and .OAuth2Providers .EnableOpenIDSignIn}}
{{template "user/auth/oauth_container" .}}
{{end}}
</div>
</div>

View File

@@ -48,7 +48,10 @@
</div>
{{end}}
{{template "user/auth/oauth_container" .}}
{{if and .OAuth2Providers .EnableOpenIDSignIn}}
<div class="divider divider-text">{{ctx.Locale.Tr "sign_in_or"}}</div>
{{template "user/auth/oauth_container" .}}
{{end}}
</form>
</div>
</div>