Skip to content

Commit 513303b

Browse files
committed
LinkAccount routes enabled for OpenID and OAuth2.
Fixes: 8faceac Related: #18491 (review) Author-Change-Id: IB#1115256
1 parent e27d6b3 commit 513303b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

routers/web/web.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ func RegisterRoutes(m *web.Route) {
188188
bindIgnErr := web.Bind
189189
validation.AddBindingRules()
190190

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+
191198
openIDSignInEnabled := func(ctx *context.Context) {
192199
if !setting.Service.EnableOpenIDSignIn {
193200
ctx.Error(http.StatusForbidden)
@@ -277,9 +284,9 @@ func RegisterRoutes(m *web.Route) {
277284
m.Get("/{provider}", auth.SignInOAuth)
278285
m.Get("/{provider}/callback", auth.SignInOAuthCallback)
279286
})
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)
283290
m.Group("/two_factor", func() {
284291
m.Get("", auth.TwoFactor)
285292
m.Post("", bindIgnErr(forms.TwoFactorAuthForm{}), auth.TwoFactorPost)
@@ -342,7 +349,7 @@ func RegisterRoutes(m *web.Route) {
342349
m.Post("/delete", security.DeleteOpenID)
343350
m.Post("/toggle_visibility", security.ToggleOpenIDVisibility)
344351
}, openIDSignInEnabled)
345-
m.Post("/account_link", openIDSignInEnabled, security.DeleteAccountLink)
352+
m.Post("/account_link", linkAccountEnabled, security.DeleteAccountLink)
346353
})
347354
m.Group("/applications/oauth2", func() {
348355
m.Get("/{id}", user_setting.OAuth2ApplicationShow)

0 commit comments

Comments
 (0)