Skip to content

Commit f9a025f

Browse files
GiteaBotyp05327
andauthored
Fix empty field login_name in API response JSON when creating user (#30511) (#30516)
Backport #30511 by @yp05327 Fix #30508 ps: if `sourceID` is not set, `LoginName` will be ignored Co-authored-by: yp05327 <[email protected]>
1 parent 00179f6 commit f9a025f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

routers/api/v1/admin/user.go

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

33-
func parseAuthSource(ctx *context.APIContext, u *user_model.User, sourceID int64, loginName string) {
33+
func parseAuthSource(ctx *context.APIContext, u *user_model.User, sourceID int64) {
3434
if sourceID == 0 {
3535
return
3636
}
@@ -47,7 +47,6 @@ func parseAuthSource(ctx *context.APIContext, u *user_model.User, sourceID int64
4747

4848
u.LoginType = source.Type
4949
u.LoginSource = source.ID
50-
u.LoginName = loginName
5150
}
5251

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

91-
parseAuthSource(ctx, u, form.SourceID, form.LoginName)
91+
parseAuthSource(ctx, u, form.SourceID)
9292
if ctx.Written() {
9393
return
9494
}

0 commit comments

Comments
 (0)