@@ -37,6 +37,7 @@ import (
37
37
"github.com/go-macaron/session"
38
38
"github.com/go-macaron/toolbox"
39
39
"gopkg.in/macaron.v1"
40
+ "net/http"
40
41
)
41
42
42
43
// NewMacaron initializes Macaron instance.
@@ -217,35 +218,54 @@ func RegisterRoutes(m *macaron.Macaron) {
217
218
m .Group ("/user/settings" , func () {
218
219
m .Get ("" , user .Settings )
219
220
m .Post ("" , bindIgnErr (auth.UpdateProfileForm {}), user .SettingsPost )
220
- m .Combo ("/avatar" ).Get (user .SettingsAvatar ).
221
- Post (binding .MultipartForm (auth.AvatarForm {}), user .SettingsAvatarPost )
221
+ m .Post ("/avatar" , binding .MultipartForm (auth.AvatarForm {}), user .SettingsAvatarPost )
222
222
m .Post ("/avatar/delete" , user .SettingsDeleteAvatar )
223
- m .Combo ("/email" ).Get (user .SettingsEmails ).
224
- Post (bindIgnErr (auth.AddEmailForm {}), user .SettingsEmailPost )
225
- m .Post ("/email/delete" , user .DeleteEmail )
226
- m .Get ("/security" , user .SettingsSecurity )
227
- m .Post ("/security" , bindIgnErr (auth.ChangePasswordForm {}), user .SettingsSecurityPost )
228
- m .Group ("/openid" , func () {
229
- m .Combo ("" ).Get (user .SettingsOpenID ).
230
- Post (bindIgnErr (auth.AddOpenIDForm {}), user .SettingsOpenIDPost )
231
- m .Post ("/delete" , user .DeleteOpenID )
232
- m .Post ("/toggle_visibility" , user .ToggleOpenIDVisibility )
233
- }, openIDSignInEnabled )
234
- m .Combo ("/keys" ).Get (user .SettingsKeys ).
235
- Post (bindIgnErr (auth.AddKeyForm {}), user .SettingsKeysPost )
236
- m .Post ("/keys/delete" , user .DeleteKey )
223
+ m .Group ("/account" , func () {
224
+ m .Combo ("" ).Get (user .SettingsAccount ).Post (bindIgnErr (auth.ChangePasswordForm {}), user .SettingsAccountPost )
225
+ m .Post ("/email" , bindIgnErr (auth.AddEmailForm {}), user .SettingsEmailPost )
226
+ m .Post ("/email/delete" , user .DeleteEmail )
227
+ m .Post ("/delete" , user .SettingsDelete )
228
+ })
229
+ m .Group ("/security" , func () {
230
+ m .Get ("" , user .SettingsSecurity )
231
+ m .Group ("/two_factor" , func () {
232
+ m .Post ("/regenerate_scratch" , user .SettingsTwoFactorRegenerateScratch )
233
+ m .Post ("/disable" , user .SettingsTwoFactorDisable )
234
+ m .Get ("/enroll" , user .SettingsTwoFactorEnroll )
235
+ m .Post ("/enroll" , bindIgnErr (auth.TwoFactorAuthForm {}), user .SettingsTwoFactorEnrollPost )
236
+ })
237
+ m .Group ("/openid" , func () {
238
+ m .Post ("" , bindIgnErr (auth.AddOpenIDForm {}), user .SettingsOpenIDPost )
239
+ m .Post ("/delete" , user .DeleteOpenID )
240
+ m .Post ("/toggle_visibility" , user .ToggleOpenIDVisibility )
241
+ }, openIDSignInEnabled )
242
+ m .Post ("/account_link" , user .SettingsDeleteAccountLink )
243
+ })
237
244
m .Combo ("/applications" ).Get (user .SettingsApplications ).
238
245
Post (bindIgnErr (auth.NewAccessTokenForm {}), user .SettingsApplicationsPost )
239
246
m .Post ("/applications/delete" , user .SettingsDeleteApplication )
240
- m .Route ("/delete" , "GET,POST" , user .SettingsDelete )
241
- m .Combo ("/account_link" ).Get (user .SettingsAccountLinks ).Post (user .SettingsDeleteAccountLink )
247
+ m .Combo ("/keys" ).Get (user .SettingsKeys ).
248
+ Post (bindIgnErr (auth.AddKeyForm {}), user .SettingsKeysPost )
249
+ m .Post ("/keys/delete" , user .DeleteKey )
242
250
m .Get ("/organization" , user .SettingsOrganization )
243
251
m .Get ("/repos" , user .SettingsRepos )
244
- m .Group ("/security/two_factor" , func () {
245
- m .Post ("/regenerate_scratch" , user .SettingsTwoFactorRegenerateScratch )
246
- m .Post ("/disable" , user .SettingsTwoFactorDisable )
247
- m .Get ("/enroll" , user .SettingsTwoFactorEnroll )
248
- m .Post ("/enroll" , bindIgnErr (auth.TwoFactorAuthForm {}), user .SettingsTwoFactorEnrollPost )
252
+
253
+ // redirects from old settings urls to new ones
254
+ // TODO: can be removed on next major version
255
+ m .Get ("/avatar" , func (ctx * context.Context ) {
256
+ ctx .Redirect (setting .AppSubURL + "/user/settings" , http .StatusMovedPermanently )
257
+ })
258
+ m .Get ("/email" , func (ctx * context.Context ) {
259
+ ctx .Redirect (setting .AppSubURL + "/user/settings/account" , http .StatusMovedPermanently )
260
+ })
261
+ m .Get ("/delete" , func (ctx * context.Context ) {
262
+ ctx .Redirect (setting .AppSubURL + "/user/settings/account" , http .StatusMovedPermanently )
263
+ })
264
+ m .Get ("/openid" , func (ctx * context.Context ) {
265
+ ctx .Redirect (setting .AppSubURL + "/user/settings/security" , http .StatusMovedPermanently )
266
+ })
267
+ m .Get ("/account_link" , func (ctx * context.Context ) {
268
+ ctx .Redirect (setting .AppSubURL + "/user/settings/security" , http .StatusMovedPermanently )
249
269
})
250
270
}, reqSignIn , func (ctx * context.Context ) {
251
271
ctx .Data ["PageIsUserSettings" ] = true
0 commit comments