mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Disable unnecessary OpenID/OAuth2 elements (#18491)
This mod fixes disabling unnecessary OpenID elements. Related: https://github.com/go-gitea/gitea/pull/13129 Author-Change-Id: IB#1115256
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							eb748f5f3c
						
					
				
				
					commit
					c917f2df9b
				
			@@ -190,6 +190,13 @@ func RegisterRoutes(m *web.Route) {
 | 
				
			|||||||
	bindIgnErr := web.Bind
 | 
						bindIgnErr := web.Bind
 | 
				
			||||||
	validation.AddBindingRules()
 | 
						validation.AddBindingRules()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						linkAccountEnabled := func(ctx *context.Context) {
 | 
				
			||||||
 | 
							if !setting.Service.EnableOpenIDSignIn && !setting.Service.EnableOpenIDSignUp && !setting.OAuth2.Enable {
 | 
				
			||||||
 | 
								ctx.Error(http.StatusForbidden)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	openIDSignInEnabled := func(ctx *context.Context) {
 | 
						openIDSignInEnabled := func(ctx *context.Context) {
 | 
				
			||||||
		if !setting.Service.EnableOpenIDSignIn {
 | 
							if !setting.Service.EnableOpenIDSignIn {
 | 
				
			||||||
			ctx.Error(http.StatusForbidden)
 | 
								ctx.Error(http.StatusForbidden)
 | 
				
			||||||
@@ -279,9 +286,9 @@ func RegisterRoutes(m *web.Route) {
 | 
				
			|||||||
			m.Get("/{provider}", auth.SignInOAuth)
 | 
								m.Get("/{provider}", auth.SignInOAuth)
 | 
				
			||||||
			m.Get("/{provider}/callback", auth.SignInOAuthCallback)
 | 
								m.Get("/{provider}/callback", auth.SignInOAuthCallback)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
		m.Get("/link_account", auth.LinkAccount)
 | 
							m.Get("/link_account", linkAccountEnabled, auth.LinkAccount)
 | 
				
			||||||
		m.Post("/link_account_signin", bindIgnErr(forms.SignInForm{}), auth.LinkAccountPostSignIn)
 | 
							m.Post("/link_account_signin", linkAccountEnabled, bindIgnErr(forms.SignInForm{}), auth.LinkAccountPostSignIn)
 | 
				
			||||||
		m.Post("/link_account_signup", bindIgnErr(forms.RegisterForm{}), auth.LinkAccountPostRegister)
 | 
							m.Post("/link_account_signup", linkAccountEnabled, bindIgnErr(forms.RegisterForm{}), auth.LinkAccountPostRegister)
 | 
				
			||||||
		m.Group("/two_factor", func() {
 | 
							m.Group("/two_factor", func() {
 | 
				
			||||||
			m.Get("", auth.TwoFactor)
 | 
								m.Get("", auth.TwoFactor)
 | 
				
			||||||
			m.Post("", bindIgnErr(forms.TwoFactorAuthForm{}), auth.TwoFactorPost)
 | 
								m.Post("", bindIgnErr(forms.TwoFactorAuthForm{}), auth.TwoFactorPost)
 | 
				
			||||||
@@ -345,7 +352,7 @@ func RegisterRoutes(m *web.Route) {
 | 
				
			|||||||
				m.Post("/delete", security.DeleteOpenID)
 | 
									m.Post("/delete", security.DeleteOpenID)
 | 
				
			||||||
				m.Post("/toggle_visibility", security.ToggleOpenIDVisibility)
 | 
									m.Post("/toggle_visibility", security.ToggleOpenIDVisibility)
 | 
				
			||||||
			}, openIDSignInEnabled)
 | 
								}, openIDSignInEnabled)
 | 
				
			||||||
			m.Post("/account_link", security.DeleteAccountLink)
 | 
								m.Post("/account_link", linkAccountEnabled, security.DeleteAccountLink)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
		m.Group("/applications/oauth2", func() {
 | 
							m.Group("/applications/oauth2", func() {
 | 
				
			||||||
			m.Get("/{id}", user_setting.OAuth2ApplicationShow)
 | 
								m.Get("/{id}", user_setting.OAuth2ApplicationShow)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user