Skip to content

Commit dfbc530

Browse files
yp05327GiteaBot
authored andcommitted
Fix empty field login_name in API response JSON when creating user (go-gitea#30511)
Fix go-gitea#30508 ps: if `sourceID` is not set, `LoginName` will be ignored
1 parent acdcfcc commit dfbc530

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
@@ -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
}

0 commit comments

Comments
 (0)