summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/setting/applications.go5
-rw-r--r--routers/user/setting/oauth2.go19
2 files changed, 24 insertions, 0 deletions
diff --git a/routers/user/setting/applications.go b/routers/user/setting/applications.go
index bc8633f72d..90e34d9e1a 100644
--- a/routers/user/setting/applications.go
+++ b/routers/user/setting/applications.go
@@ -81,5 +81,10 @@ func loadApplicationsData(ctx *context.Context) {
ctx.ServerError("GetOAuth2ApplicationsByUserID", err)
return
}
+ ctx.Data["Grants"], err = models.GetOAuth2GrantsByUserID(ctx.User.ID)
+ if err != nil {
+ ctx.ServerError("GetOAuth2GrantsByUserID", err)
+ return
+ }
}
}
diff --git a/routers/user/setting/oauth2.go b/routers/user/setting/oauth2.go
index 1068b5db49..265e32642b 100644
--- a/routers/user/setting/oauth2.go
+++ b/routers/user/setting/oauth2.go
@@ -5,6 +5,8 @@
package setting
import (
+ "fmt"
+
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/base"
@@ -138,3 +140,20 @@ func DeleteOAuth2Application(ctx *context.Context) {
"redirect": setting.AppSubURL + "/user/settings/applications",
})
}
+
+// RevokeOAuth2Grant revokes the grant with the given id
+func RevokeOAuth2Grant(ctx *context.Context) {
+ if ctx.User.ID == 0 || ctx.QueryInt64("id") == 0 {
+ ctx.ServerError("RevokeOAuth2Grant", fmt.Errorf("user id or grant id is zero"))
+ return
+ }
+ if err := models.RevokeOAuth2Grant(ctx.QueryInt64("id"), ctx.User.ID); err != nil {
+ ctx.ServerError("RevokeOAuth2Grant", err)
+ return
+ }
+
+ ctx.Flash.Success(ctx.Tr("settings.revoke_oauth2_grant_success"))
+ ctx.JSON(200, map[string]interface{}{
+ "redirect": setting.AppSubURL + "/user/settings/applications",
+ })
+}