diff options
author | renothing <261274+renothing@users.noreply.github.com> | 2019-07-27 21:15:30 +0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-07-27 16:15:30 +0300 |
commit | cbf231a67595feb36fccb68dc00b2bc7607fa882 (patch) | |
tree | 9f200fb9c89dc79a2f6a6472901668753a742aa3 /routers/api/v1/admin | |
parent | 700cd346fad3a0bed203bfb032f7b4bc9d1f2551 (diff) | |
download | gitea-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/admin')
-rw-r--r-- | routers/api/v1/admin/user.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 6dc3b0325b..f4b694aa22 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -91,8 +91,7 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) { if form.SendNotify && setting.MailService != nil { models.SendRegisterNotifyMail(ctx.Context.Context, u) } - - ctx.JSON(201, u.APIFormat()) + ctx.JSON(201, convert.ToUser(u, ctx.IsSigned, ctx.User.IsAdmin)) } // EditUser api for modifying a user's information @@ -181,7 +180,7 @@ func EditUser(ctx *context.APIContext, form api.EditUserOption) { } log.Trace("Account profile updated by admin (%s): %s", ctx.User.Name, u.Name) - ctx.JSON(200, u.APIFormat()) + ctx.JSON(200, convert.ToUser(u, ctx.IsSigned, ctx.User.IsAdmin)) } // DeleteUser api for deleting a user @@ -326,7 +325,7 @@ func GetAllUsers(ctx *context.APIContext) { results := make([]*api.User, len(users)) for i := range users { - results[i] = convert.ToUser(users[i], ctx.IsSigned, ctx.User != nil && ctx.User.IsAdmin) + results[i] = convert.ToUser(users[i], ctx.IsSigned, ctx.User.IsAdmin) } ctx.JSON(200, &results) |