mirror of https://github.com/go-gitea/gitea.git
Merge 69afd9dc39
into c93eefb42b
This commit is contained in:
commit
2a2a845de3
|
@ -945,7 +945,6 @@ func Routes() *web.Route {
|
|||
// Users (requires user scope)
|
||||
m.Group("/users", func() {
|
||||
m.Group("/{username}", func() {
|
||||
m.Get("/keys", user.ListPublicKeys)
|
||||
m.Get("/gpg_keys", user.ListGPGKeys)
|
||||
|
||||
m.Get("/followers", user.ListFollowers)
|
||||
|
@ -960,6 +959,13 @@ func Routes() *web.Route {
|
|||
}, context.UserAssignmentAPI())
|
||||
}, tokenRequiresScopes(auth_model.AccessTokenScopeCategoryUser), reqToken())
|
||||
|
||||
// Users SSH keys (publicly readable)
|
||||
m.Group("/users", func() {
|
||||
m.Group("/{username}", func() {
|
||||
m.Get("/keys", user.ListPublicKeys)
|
||||
}, context.UserAssignmentAPI())
|
||||
})
|
||||
|
||||
// Users (requires user scope)
|
||||
m.Group("/user", func() {
|
||||
m.Get("", user.GetAuthenticatedUser)
|
||||
|
|
|
@ -89,8 +89,14 @@ func listPublicKeys(ctx *context.APIContext, user *user_model.User) {
|
|||
apiKeys := make([]*api.PublicKey, len(keys))
|
||||
for i := range keys {
|
||||
apiKeys[i] = convert.ToPublicKey(apiLink, keys[i])
|
||||
if ctx.Doer.IsAdmin || ctx.Doer.ID == keys[i].OwnerID {
|
||||
apiKeys[i], _ = appendPrivateInformation(ctx, apiKeys[i], keys[i], user)
|
||||
if ctx.Doer != nil {
|
||||
if ctx.Doer.IsAdmin || ctx.Doer.ID == keys[i].OwnerID {
|
||||
apiKeys[i], _ = appendPrivateInformation(ctx, apiKeys[i], keys[i], user)
|
||||
}
|
||||
} else {
|
||||
// unauthenticated requests will not receive the title property
|
||||
// to preserve privacy
|
||||
apiKeys[i].Title = ""
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue