@@ -188,6 +188,13 @@ func RegisterRoutes(m *web.Route) {
188
188
bindIgnErr := web .Bind
189
189
validation .AddBindingRules ()
190
190
191
+ linkAccountEnabled := func (ctx * context.Context ) {
192
+ if ! setting .Service .EnableOpenIDSignIn && ! setting .Service .EnableOpenIDSignUp && ! setting .OAuth2 .Enable {
193
+ ctx .Error (http .StatusForbidden )
194
+ return
195
+ }
196
+ }
197
+
191
198
openIDSignInEnabled := func (ctx * context.Context ) {
192
199
if ! setting .Service .EnableOpenIDSignIn {
193
200
ctx .Error (http .StatusForbidden )
@@ -277,9 +284,9 @@ func RegisterRoutes(m *web.Route) {
277
284
m .Get ("/{provider}" , auth .SignInOAuth )
278
285
m .Get ("/{provider}/callback" , auth .SignInOAuthCallback )
279
286
})
280
- m .Get ("/link_account" , openIDSignInEnabled , auth .LinkAccount )
281
- m .Post ("/link_account_signin" , openIDSignInEnabled , bindIgnErr (forms.SignInForm {}), auth .LinkAccountPostSignIn )
282
- m .Post ("/link_account_signup" , openIDSignUpEnabled , bindIgnErr (forms.RegisterForm {}), auth .LinkAccountPostRegister )
287
+ m .Get ("/link_account" , linkAccountEnabled , auth .LinkAccount )
288
+ m .Post ("/link_account_signin" , linkAccountEnabled , bindIgnErr (forms.SignInForm {}), auth .LinkAccountPostSignIn )
289
+ m .Post ("/link_account_signup" , linkAccountEnabled , bindIgnErr (forms.RegisterForm {}), auth .LinkAccountPostRegister )
283
290
m .Group ("/two_factor" , func () {
284
291
m .Get ("" , auth .TwoFactor )
285
292
m .Post ("" , bindIgnErr (forms.TwoFactorAuthForm {}), auth .TwoFactorPost )
@@ -342,7 +349,7 @@ func RegisterRoutes(m *web.Route) {
342
349
m .Post ("/delete" , security .DeleteOpenID )
343
350
m .Post ("/toggle_visibility" , security .ToggleOpenIDVisibility )
344
351
}, openIDSignInEnabled )
345
- m .Post ("/account_link" , openIDSignInEnabled , security .DeleteAccountLink )
352
+ m .Post ("/account_link" , linkAccountEnabled , security .DeleteAccountLink )
346
353
})
347
354
m .Group ("/applications/oauth2" , func () {
348
355
m .Get ("/{id}" , user_setting .OAuth2ApplicationShow )
0 commit comments