|
|
@ -136,6 +136,20 @@ func RegisterRoutes(m *macaron.Macaron) { |
|
|
|
bindIgnErr := binding.BindIgnErr |
|
|
|
bindIgnErr := binding.BindIgnErr |
|
|
|
validation.AddBindingRules() |
|
|
|
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) |
|
|
|
m.Use(user.GetNotificationCount) |
|
|
|
|
|
|
|
|
|
|
|
// FIXME: not all routes need go through same middlewares.
|
|
|
|
// FIXME: not all routes need go through same middlewares.
|
|
|
@ -163,19 +177,21 @@ func RegisterRoutes(m *macaron.Macaron) { |
|
|
|
m.Group("/user", func() { |
|
|
|
m.Group("/user", func() { |
|
|
|
m.Get("/login", user.SignIn) |
|
|
|
m.Get("/login", user.SignIn) |
|
|
|
m.Post("/login", bindIgnErr(auth.SignInForm{}), user.SignInPost) |
|
|
|
m.Post("/login", bindIgnErr(auth.SignInForm{}), user.SignInPost) |
|
|
|
if setting.Service.EnableOpenIDSignIn { |
|
|
|
m.Group("", func() { |
|
|
|
m.Combo("/login/openid"). |
|
|
|
m.Combo("/login/openid"). |
|
|
|
Get(user.SignInOpenID). |
|
|
|
Get(user.SignInOpenID). |
|
|
|
Post(bindIgnErr(auth.SignInOpenIDForm{}), user.SignInOpenIDPost) |
|
|
|
Post(bindIgnErr(auth.SignInOpenIDForm{}), user.SignInOpenIDPost) |
|
|
|
|
|
|
|
}, openIDSignInEnabled) |
|
|
|
m.Group("/openid", func() { |
|
|
|
m.Group("/openid", func() { |
|
|
|
m.Combo("/connect"). |
|
|
|
m.Combo("/connect"). |
|
|
|
Get(user.ConnectOpenID). |
|
|
|
Get(user.ConnectOpenID). |
|
|
|
Post(bindIgnErr(auth.ConnectOpenIDForm{}), user.ConnectOpenIDPost) |
|
|
|
Post(bindIgnErr(auth.ConnectOpenIDForm{}), user.ConnectOpenIDPost) |
|
|
|
m.Combo("/register"). |
|
|
|
m.Group("/register", func() { |
|
|
|
Get(user.RegisterOpenID). |
|
|
|
m.Combo(""). |
|
|
|
|
|
|
|
Get(user.RegisterOpenID, openIDSignUpEnabled). |
|
|
|
Post(bindIgnErr(auth.SignUpOpenIDForm{}), user.RegisterOpenIDPost) |
|
|
|
Post(bindIgnErr(auth.SignUpOpenIDForm{}), user.RegisterOpenIDPost) |
|
|
|
}) |
|
|
|
}, openIDSignUpEnabled) |
|
|
|
} |
|
|
|
}, openIDSignInEnabled) |
|
|
|
m.Get("/sign_up", user.SignUp) |
|
|
|
m.Get("/sign_up", user.SignUp) |
|
|
|
m.Post("/sign_up", bindIgnErr(auth.RegisterForm{}), user.SignUpPost) |
|
|
|
m.Post("/sign_up", bindIgnErr(auth.RegisterForm{}), user.SignUpPost) |
|
|
|
m.Get("/reset_password", user.ResetPasswd) |
|
|
|
m.Get("/reset_password", user.ResetPasswd) |
|
|
@ -206,15 +222,12 @@ func RegisterRoutes(m *macaron.Macaron) { |
|
|
|
m.Post("/email/delete", user.DeleteEmail) |
|
|
|
m.Post("/email/delete", user.DeleteEmail) |
|
|
|
m.Get("/password", user.SettingsPassword) |
|
|
|
m.Get("/password", user.SettingsPassword) |
|
|
|
m.Post("/password", bindIgnErr(auth.ChangePasswordForm{}), user.SettingsPasswordPost) |
|
|
|
m.Post("/password", bindIgnErr(auth.ChangePasswordForm{}), user.SettingsPasswordPost) |
|
|
|
if setting.Service.EnableOpenIDSignIn { |
|
|
|
|
|
|
|
m.Group("/openid", func() { |
|
|
|
m.Group("/openid", func() { |
|
|
|
m.Combo("").Get(user.SettingsOpenID). |
|
|
|
m.Combo("").Get(user.SettingsOpenID). |
|
|
|
Post(bindIgnErr(auth.AddOpenIDForm{}), user.SettingsOpenIDPost) |
|
|
|
Post(bindIgnErr(auth.AddOpenIDForm{}), user.SettingsOpenIDPost) |
|
|
|
m.Post("/delete", user.DeleteOpenID) |
|
|
|
m.Post("/delete", user.DeleteOpenID) |
|
|
|
m.Post("/toggle_visibility", user.ToggleOpenIDVisibility) |
|
|
|
m.Post("/toggle_visibility", user.ToggleOpenIDVisibility) |
|
|
|
}) |
|
|
|
}, openIDSignInEnabled) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m.Combo("/keys").Get(user.SettingsKeys). |
|
|
|
m.Combo("/keys").Get(user.SettingsKeys). |
|
|
|
Post(bindIgnErr(auth.AddKeyForm{}), user.SettingsKeysPost) |
|
|
|
Post(bindIgnErr(auth.AddKeyForm{}), user.SettingsKeysPost) |
|
|
|
m.Post("/keys/delete", user.DeleteKey) |
|
|
|
m.Post("/keys/delete", user.DeleteKey) |
|
|
|