summaryrefslogtreecommitdiffstats
path: root/routers/routes
diff options
context:
space:
mode:
authorDavid Schneiderbauer <daviian@users.noreply.github.com>2018-05-15 12:07:32 +0200
committerLauris BH <lauris@nix.lv>2018-05-15 13:07:32 +0300
commit099372d76c411c598285d637bd85c9b2dbc40948 (patch)
treebce801f16b8534e2ca0dadcbc24455de95f0501c /routers/routes
parent1546458f7df4a4f0e77b7ae5cb65baed6feae394 (diff)
downloadgitea-099372d76c411c598285d637bd85c9b2dbc40948.tar.gz
gitea-099372d76c411c598285d637bd85c9b2dbc40948.zip
Refactor User Settings (#3900)
* moved avatar to profile page * combined password change, email and account deletion into account settings page * combined totp, access tokens, linked accounts and openid into security settings page * move access tokens to applications settings page * small change to restart drone build * fix change avatar url on profile page * redirect old settings urls to new ones * enforce only one autofocus attribute on settings pages * set correct redirect status code * fmt fix
Diffstat (limited to 'routers/routes')
-rw-r--r--routers/routes/routes.go66
1 files changed, 43 insertions, 23 deletions
diff --git a/routers/routes/routes.go b/routers/routes/routes.go
index 9618d25268..40b5f4bfb3 100644
--- a/routers/routes/routes.go
+++ b/routers/routes/routes.go
@@ -37,6 +37,7 @@ import (
"github.com/go-macaron/session"
"github.com/go-macaron/toolbox"
"gopkg.in/macaron.v1"
+ "net/http"
)
// NewMacaron initializes Macaron instance.
@@ -217,35 +218,54 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/user/settings", func() {
m.Get("", user.Settings)
m.Post("", bindIgnErr(auth.UpdateProfileForm{}), user.SettingsPost)
- m.Combo("/avatar").Get(user.SettingsAvatar).
- Post(binding.MultipartForm(auth.AvatarForm{}), user.SettingsAvatarPost)
+ m.Post("/avatar", binding.MultipartForm(auth.AvatarForm{}), user.SettingsAvatarPost)
m.Post("/avatar/delete", user.SettingsDeleteAvatar)
- m.Combo("/email").Get(user.SettingsEmails).
- Post(bindIgnErr(auth.AddEmailForm{}), user.SettingsEmailPost)
- m.Post("/email/delete", user.DeleteEmail)
- m.Get("/security", user.SettingsSecurity)
- m.Post("/security", bindIgnErr(auth.ChangePasswordForm{}), user.SettingsSecurityPost)
- 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)
+ m.Group("/account", func() {
+ m.Combo("").Get(user.SettingsAccount).Post(bindIgnErr(auth.ChangePasswordForm{}), user.SettingsAccountPost)
+ m.Post("/email", bindIgnErr(auth.AddEmailForm{}), user.SettingsEmailPost)
+ m.Post("/email/delete", user.DeleteEmail)
+ m.Post("/delete", user.SettingsDelete)
+ })
+ m.Group("/security", func() {
+ m.Get("", user.SettingsSecurity)
+ m.Group("/two_factor", func() {
+ m.Post("/regenerate_scratch", user.SettingsTwoFactorRegenerateScratch)
+ m.Post("/disable", user.SettingsTwoFactorDisable)
+ m.Get("/enroll", user.SettingsTwoFactorEnroll)
+ m.Post("/enroll", bindIgnErr(auth.TwoFactorAuthForm{}), user.SettingsTwoFactorEnrollPost)
+ })
+ m.Group("/openid", func() {
+ m.Post("", bindIgnErr(auth.AddOpenIDForm{}), user.SettingsOpenIDPost)
+ m.Post("/delete", user.DeleteOpenID)
+ m.Post("/toggle_visibility", user.ToggleOpenIDVisibility)
+ }, openIDSignInEnabled)
+ m.Post("/account_link", user.SettingsDeleteAccountLink)
+ })
m.Combo("/applications").Get(user.SettingsApplications).
Post(bindIgnErr(auth.NewAccessTokenForm{}), user.SettingsApplicationsPost)
m.Post("/applications/delete", user.SettingsDeleteApplication)
- m.Route("/delete", "GET,POST", user.SettingsDelete)
- m.Combo("/account_link").Get(user.SettingsAccountLinks).Post(user.SettingsDeleteAccountLink)
+ m.Combo("/keys").Get(user.SettingsKeys).
+ Post(bindIgnErr(auth.AddKeyForm{}), user.SettingsKeysPost)
+ m.Post("/keys/delete", user.DeleteKey)
m.Get("/organization", user.SettingsOrganization)
m.Get("/repos", user.SettingsRepos)
- m.Group("/security/two_factor", func() {
- m.Post("/regenerate_scratch", user.SettingsTwoFactorRegenerateScratch)
- m.Post("/disable", user.SettingsTwoFactorDisable)
- m.Get("/enroll", user.SettingsTwoFactorEnroll)
- m.Post("/enroll", bindIgnErr(auth.TwoFactorAuthForm{}), user.SettingsTwoFactorEnrollPost)
+
+ // redirects from old settings urls to new ones
+ // TODO: can be removed on next major version
+ m.Get("/avatar", func(ctx *context.Context) {
+ ctx.Redirect(setting.AppSubURL+"/user/settings", http.StatusMovedPermanently)
+ })
+ m.Get("/email", func(ctx *context.Context) {
+ ctx.Redirect(setting.AppSubURL+"/user/settings/account", http.StatusMovedPermanently)
+ })
+ m.Get("/delete", func(ctx *context.Context) {
+ ctx.Redirect(setting.AppSubURL+"/user/settings/account", http.StatusMovedPermanently)
+ })
+ m.Get("/openid", func(ctx *context.Context) {
+ ctx.Redirect(setting.AppSubURL+"/user/settings/security", http.StatusMovedPermanently)
+ })
+ m.Get("/account_link", func(ctx *context.Context) {
+ ctx.Redirect(setting.AppSubURL+"/user/settings/security", http.StatusMovedPermanently)
})
}, reqSignIn, func(ctx *context.Context) {
ctx.Data["PageIsUserSettings"] = true