Skip to content

Commit a82bf02

Browse files
authored
Fix empty field login_name in API response JSON when creating user (#30511) (#30532)
Backport #30511 Fix ci error in #30515
1 parent acdcfcc commit a82bf02

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

routers/api/v1/admin/user.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
user_service "code.gitea.io/gitea/services/user"
3232
)
3333

34-
func parseAuthSource(ctx *context.APIContext, u *user_model.User, sourceID int64, loginName string) {
34+
func parseAuthSource(ctx *context.APIContext, u *user_model.User, sourceID int64) {
3535
if sourceID == 0 {
3636
return
3737
}
@@ -48,7 +48,6 @@ func parseAuthSource(ctx *context.APIContext, u *user_model.User, sourceID int64
4848

4949
u.LoginType = source.Type
5050
u.LoginSource = source.ID
51-
u.LoginName = loginName
5251
}
5352

5453
// CreateUser create a user
@@ -84,12 +83,13 @@ func CreateUser(ctx *context.APIContext) {
8483
Passwd: form.Password,
8584
MustChangePassword: true,
8685
LoginType: auth.Plain,
86+
LoginName: form.LoginName,
8787
}
8888
if form.MustChangePassword != nil {
8989
u.MustChangePassword = *form.MustChangePassword
9090
}
9191

92-
parseAuthSource(ctx, u, form.SourceID, form.LoginName)
92+
parseAuthSource(ctx, u, form.SourceID)
9393
if ctx.Written() {
9494
return
9595
}
@@ -192,7 +192,7 @@ func EditUser(ctx *context.APIContext) {
192192

193193
form := web.GetForm(ctx).(*api.EditUserOption)
194194

195-
parseAuthSource(ctx, ctx.ContextUser, form.SourceID, form.LoginName)
195+
parseAuthSource(ctx, ctx.ContextUser, form.SourceID)
196196
if ctx.Written() {
197197
return
198198
}

0 commit comments

Comments
 (0)