Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,15 @@ func RegisterRoutes(m *web.Route) {
m.Get("/{provider}", auth.SignInOAuth)
m.Get("/{provider}/callback", auth.SignInOAuthCallback)
})
m.Get("/link_account", auth.LinkAccount)
m.Post("/link_account_signin", bindIgnErr(forms.SignInForm{}), auth.LinkAccountPostSignIn)
m.Post("/link_account_signup", bindIgnErr(forms.RegisterForm{}), auth.LinkAccountPostRegister)
m.Group("/link_account", func() {
m.Get("", auth.LinkAccount)
}, openIDSignInEnabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openIDSignInEnabled can be added to the Get and Post arguments, no need to go all fancy with Group here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested that

m.Get("/", Home, openIDSignInEnabled)

does not forbid access to / when openIDSignInEnabled is disabled but

m.Group("/", func() {
		m.Get("", Home)
	}, openIDSignInEnabled)

does. Seems that simply adding openIDSignInEnabled to Get arguments does not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m.Get("/", openIDSignInEnabled, Home)

works ok - will fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

m.Group("/link_account_signin", func() {
m.Post("", bindIgnErr(forms.SignInForm{}), auth.LinkAccountPostSignIn)
}, openIDSignInEnabled)
m.Group("/link_account_signup", func() {
m.Post("", bindIgnErr(forms.RegisterForm{}), auth.LinkAccountPostRegister)
}, openIDSignUpEnabled)
m.Group("/two_factor", func() {
m.Get("", auth.TwoFactor)
m.Post("", bindIgnErr(forms.TwoFactorAuthForm{}), auth.TwoFactorPost)
Expand Down Expand Up @@ -342,7 +348,9 @@ func RegisterRoutes(m *web.Route) {
m.Post("/delete", security.DeleteOpenID)
m.Post("/toggle_visibility", security.ToggleOpenIDVisibility)
}, openIDSignInEnabled)
m.Post("/account_link", security.DeleteAccountLink)
m.Group("/account_link", func() {
m.Post("", security.DeleteAccountLink)
}, openIDSignInEnabled)
})
m.Group("/applications/oauth2", func() {
m.Get("/{id}", user_setting.OAuth2ApplicationShow)
Expand Down