@@ -190,6 +190,13 @@ func RegisterRoutes(m *web.Route) {
190
190
bindIgnErr := web .Bind
191
191
validation .AddBindingRules ()
192
192
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
+
193
200
openIDSignInEnabled := func (ctx * context.Context ) {
194
201
if ! setting .Service .EnableOpenIDSignIn {
195
202
ctx .Error (http .StatusForbidden )
@@ -279,9 +286,9 @@ func RegisterRoutes(m *web.Route) {
279
286
m .Get ("/{provider}" , auth .SignInOAuth )
280
287
m .Get ("/{provider}/callback" , auth .SignInOAuthCallback )
281
288
})
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 )
285
292
m .Group ("/two_factor" , func () {
286
293
m .Get ("" , auth .TwoFactor )
287
294
m .Post ("" , bindIgnErr (forms.TwoFactorAuthForm {}), auth .TwoFactorPost )
@@ -345,7 +352,7 @@ func RegisterRoutes(m *web.Route) {
345
352
m .Post ("/delete" , security .DeleteOpenID )
346
353
m .Post ("/toggle_visibility" , security .ToggleOpenIDVisibility )
347
354
}, openIDSignInEnabled )
348
- m .Post ("/account_link" , security .DeleteAccountLink )
355
+ m .Post ("/account_link" , linkAccountEnabled , security .DeleteAccountLink )
349
356
})
350
357
m .Group ("/applications/oauth2" , func () {
351
358
m .Get ("/{id}" , user_setting .OAuth2ApplicationShow )
0 commit comments