summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/subscriber.go
diff options
context:
space:
mode:
authorrenothing <261274+renothing@users.noreply.github.com>2019-07-27 21:15:30 +0800
committerLauris BH <lauris@nix.lv>2019-07-27 16:15:30 +0300
commitcbf231a67595feb36fccb68dc00b2bc7607fa882 (patch)
tree9f200fb9c89dc79a2f6a6472901668753a742aa3 /routers/api/v1/repo/subscriber.go
parent700cd346fad3a0bed203bfb032f7b4bc9d1f2551 (diff)
downloadgitea-cbf231a67595feb36fccb68dc00b2bc7607fa882.tar.gz
gitea-cbf231a67595feb36fccb68dc00b2bc7607fa882.zip
fix wrong email when use gitea as OAuth2 provider (#7640)
when you use gitea as OAuth2 provider, the /api/v1/user should return user primary email as identifier, which is unique in OAuth2 clients. this patch use convert.ToUser replace all u.APIFormat in api requests, return primary email when caller is yourself or admin.
Diffstat (limited to 'routers/api/v1/repo/subscriber.go')
-rw-r--r--routers/api/v1/repo/subscriber.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/routers/api/v1/repo/subscriber.go b/routers/api/v1/repo/subscriber.go
index b7d329dc78..ec0ea6dada 100644
--- a/routers/api/v1/repo/subscriber.go
+++ b/routers/api/v1/repo/subscriber.go
@@ -8,6 +8,7 @@ import (
"code.gitea.io/gitea/modules/context"
api "code.gitea.io/gitea/modules/structs"
+ "code.gitea.io/gitea/routers/api/v1/convert"
)
// ListSubscribers list a repo's subscribers (i.e. watchers)
@@ -38,7 +39,7 @@ func ListSubscribers(ctx *context.APIContext) {
}
users := make([]*api.User, len(subscribers))
for i, subscriber := range subscribers {
- users[i] = subscriber.APIFormat()
+ users[i] = convert.ToUser(subscriber, ctx.IsSigned, ctx.User != nil && ctx.User.IsAdmin)
}
ctx.JSON(200, users)
}