summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/issue.go2
-rw-r--r--routers/user/setting.go56
2 files changed, 27 insertions, 31 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 4072483e89..2fa270f373 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1013,7 +1013,7 @@ func ChangeMilestonStatus(ctx *middleware.Context) {
func DeleteMilestone(ctx *middleware.Context) {
if err := models.DeleteMilestoneByID(ctx.QueryInt64("id")); err != nil {
- ctx.Flash.Error("DeleteMilestone: " + err.Error())
+ ctx.Flash.Error("DeleteMilestoneByID: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.milestones.deletion_success"))
}
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 73919088ef..c8b9f130d4 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -374,18 +374,6 @@ func SettingsApplications(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsApplications"] = true
- // Delete access token.
- remove, _ := com.StrTo(ctx.Query("remove")).Int64()
- if remove > 0 {
- if err := models.DeleteAccessTokenById(remove); err != nil {
- ctx.Handle(500, "DeleteAccessTokenById", err)
- return
- }
- ctx.Flash.Success(ctx.Tr("settings.delete_token_success"))
- ctx.Redirect(setting.AppSubUrl + "/user/settings/applications")
- return
- }
-
tokens, err := models.ListAccessTokens(ctx.User.Id)
if err != nil {
ctx.Handle(500, "ListAccessTokens", err)
@@ -396,34 +384,42 @@ func SettingsApplications(ctx *middleware.Context) {
ctx.HTML(200, SETTINGS_APPLICATIONS)
}
-// FIXME: split to two different functions and pages to handle access token and oauth2
func SettingsApplicationsPost(ctx *middleware.Context, form auth.NewAccessTokenForm) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsApplications"] = true
- switch ctx.Query("type") {
- case "token":
- if ctx.HasError() {
- ctx.HTML(200, SETTINGS_APPLICATIONS)
- return
- }
-
- t := &models.AccessToken{
- UID: ctx.User.Id,
- Name: form.Name,
- }
- if err := models.NewAccessToken(t); err != nil {
- ctx.Handle(500, "NewAccessToken", err)
- return
- }
+ if ctx.HasError() {
+ ctx.HTML(200, SETTINGS_APPLICATIONS)
+ return
+ }
- ctx.Flash.Success(ctx.Tr("settings.generate_token_succees"))
- ctx.Flash.Info(t.Sha1)
+ t := &models.AccessToken{
+ UID: ctx.User.Id,
+ Name: form.Name,
}
+ if err := models.NewAccessToken(t); err != nil {
+ ctx.Handle(500, "NewAccessToken", err)
+ return
+ }
+
+ ctx.Flash.Success(ctx.Tr("settings.generate_token_succees"))
+ ctx.Flash.Info(t.Sha1)
ctx.Redirect(setting.AppSubUrl + "/user/settings/applications")
}
+func SettingsDeleteApplication(ctx *middleware.Context) {
+ if err := models.DeleteAccessTokenByID(ctx.QueryInt64("id")); err != nil {
+ ctx.Flash.Error("DeleteAccessTokenByID: " + err.Error())
+ } else {
+ ctx.Flash.Success(ctx.Tr("settings.delete_token_success"))
+ }
+
+ ctx.JSON(200, map[string]interface{}{
+ "redirect": setting.AppSubUrl + "/user/settings/applications",
+ })
+}
+
func SettingsDelete(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsDelete"] = true