@@ -190,6 +190,13 @@ func RegisterRoutes(m *web.Route) {
190190 bindIgnErr := web .Bind
191191 validation .AddBindingRules ()
192192
193+ linkAccountEnabled := func (ctx * context.Context ) {
194+ if ! setting .Service .EnableOpenIDSignIn && ! setting .Service .EnableOpenIDSignUp && ! setting .OAuth2 .Enable {
195+ ctx .Error (http .StatusForbidden )
196+ return
197+ }
198+ }
199+
193200 openIDSignInEnabled := func (ctx * context.Context ) {
194201 if ! setting .Service .EnableOpenIDSignIn {
195202 ctx .Error (http .StatusForbidden )
@@ -279,9 +286,9 @@ func RegisterRoutes(m *web.Route) {
279286 m .Get ("/{provider}" , auth .SignInOAuth )
280287 m .Get ("/{provider}/callback" , auth .SignInOAuthCallback )
281288 })
282- m .Get ("/link_account" , auth .LinkAccount )
283- m .Post ("/link_account_signin" , bindIgnErr (forms.SignInForm {}), auth .LinkAccountPostSignIn )
284- m .Post ("/link_account_signup" , bindIgnErr (forms.RegisterForm {}), auth .LinkAccountPostRegister )
289+ m .Get ("/link_account" , linkAccountEnabled , auth .LinkAccount )
290+ m .Post ("/link_account_signin" , linkAccountEnabled , bindIgnErr (forms.SignInForm {}), auth .LinkAccountPostSignIn )
291+ m .Post ("/link_account_signup" , linkAccountEnabled , bindIgnErr (forms.RegisterForm {}), auth .LinkAccountPostRegister )
285292 m .Group ("/two_factor" , func () {
286293 m .Get ("" , auth .TwoFactor )
287294 m .Post ("" , bindIgnErr (forms.TwoFactorAuthForm {}), auth .TwoFactorPost )
@@ -345,7 +352,7 @@ func RegisterRoutes(m *web.Route) {
345352 m .Post ("/delete" , security .DeleteOpenID )
346353 m .Post ("/toggle_visibility" , security .ToggleOpenIDVisibility )
347354 }, openIDSignInEnabled )
348- m .Post ("/account_link" , security .DeleteAccountLink )
355+ m .Post ("/account_link" , linkAccountEnabled , security .DeleteAccountLink )
349356 })
350357 m .Group ("/applications/oauth2" , func () {
351358 m .Get ("/{id}" , user_setting .OAuth2ApplicationShow )
0 commit comments