diff options
author | Sandro Santilli <strk@kbt.io> | 2017-08-19 17:34:49 +0200 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-08-19 17:34:49 +0200 |
commit | 2c3a229a3c4cc3e86c5a1130bbd058ba78022a6a (patch) | |
tree | 674c05386c007308c7b4033756eba7cc6536b58c /routers/routes/routes.go | |
parent | e7653a67a10483aa0e2c9cc019abe9021e8df9ce (diff) | |
download | gitea-2c3a229a3c4cc3e86c5a1130bbd058ba78022a6a.tar.gz gitea-2c3a229a3c4cc3e86c5a1130bbd058ba78022a6a.zip |
Add OpenID configuration in install page (#2276)
Diffstat (limited to 'routers/routes/routes.go')
-rw-r--r-- | routers/routes/routes.go | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/routers/routes/routes.go b/routers/routes/routes.go index a7a759538f..d765c4c03b 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -136,6 +136,20 @@ func RegisterRoutes(m *macaron.Macaron) { bindIgnErr := binding.BindIgnErr validation.AddBindingRules() + openIDSignInEnabled := func(ctx *context.Context) { + if !setting.Service.EnableOpenIDSignIn { + ctx.Error(403) + return + } + } + + openIDSignUpEnabled := func(ctx *context.Context) { + if !setting.Service.EnableOpenIDSignUp { + ctx.Error(403) + return + } + } + m.Use(user.GetNotificationCount) // FIXME: not all routes need go through same middlewares. @@ -163,19 +177,21 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/user", func() { m.Get("/login", user.SignIn) m.Post("/login", bindIgnErr(auth.SignInForm{}), user.SignInPost) - if setting.Service.EnableOpenIDSignIn { + m.Group("", func() { m.Combo("/login/openid"). Get(user.SignInOpenID). Post(bindIgnErr(auth.SignInOpenIDForm{}), user.SignInOpenIDPost) - m.Group("/openid", func() { - m.Combo("/connect"). - Get(user.ConnectOpenID). - Post(bindIgnErr(auth.ConnectOpenIDForm{}), user.ConnectOpenIDPost) - m.Combo("/register"). - Get(user.RegisterOpenID). + }, openIDSignInEnabled) + m.Group("/openid", func() { + m.Combo("/connect"). + Get(user.ConnectOpenID). + Post(bindIgnErr(auth.ConnectOpenIDForm{}), user.ConnectOpenIDPost) + m.Group("/register", func() { + m.Combo(""). + Get(user.RegisterOpenID, openIDSignUpEnabled). Post(bindIgnErr(auth.SignUpOpenIDForm{}), user.RegisterOpenIDPost) - }) - } + }, openIDSignUpEnabled) + }, openIDSignInEnabled) m.Get("/sign_up", user.SignUp) m.Post("/sign_up", bindIgnErr(auth.RegisterForm{}), user.SignUpPost) m.Get("/reset_password", user.ResetPasswd) @@ -206,15 +222,12 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/email/delete", user.DeleteEmail) m.Get("/password", user.SettingsPassword) m.Post("/password", bindIgnErr(auth.ChangePasswordForm{}), user.SettingsPasswordPost) - if setting.Service.EnableOpenIDSignIn { - m.Group("/openid", func() { - m.Combo("").Get(user.SettingsOpenID). - Post(bindIgnErr(auth.AddOpenIDForm{}), user.SettingsOpenIDPost) - m.Post("/delete", user.DeleteOpenID) - m.Post("/toggle_visibility", user.ToggleOpenIDVisibility) - }) - } - + m.Group("/openid", func() { + m.Combo("").Get(user.SettingsOpenID). + Post(bindIgnErr(auth.AddOpenIDForm{}), user.SettingsOpenIDPost) + m.Post("/delete", user.DeleteOpenID) + m.Post("/toggle_visibility", user.ToggleOpenIDVisibility) + }, openIDSignInEnabled) m.Combo("/keys").Get(user.SettingsKeys). Post(bindIgnErr(auth.AddKeyForm{}), user.SettingsKeysPost) m.Post("/keys/delete", user.DeleteKey) |