Skip to content

Commit

Permalink
Fix empty field login_name in API response JSON when creating user (g…
Browse files Browse the repository at this point in the history
…o-gitea#30511)

Fix go-gitea#30508

ps: if `sourceID` is not set, `LoginName` will be ignored
  • Loading branch information
yp05327 authored and GiteaBot committed Apr 16, 2024
1 parent acdcfcc commit dfbc530
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions routers/api/v1/admin/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
user_service "code.gitea.io/gitea/services/user"
)

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

u.LoginType = source.Type
u.LoginSource = source.ID
u.LoginName = loginName
}

// CreateUser create a user
Expand Down Expand Up @@ -84,12 +83,13 @@ func CreateUser(ctx *context.APIContext) {
Passwd: form.Password,
MustChangePassword: true,
LoginType: auth.Plain,
LoginName: form.LoginName,
}
if form.MustChangePassword != nil {
u.MustChangePassword = *form.MustChangePassword
}

parseAuthSource(ctx, u, form.SourceID, form.LoginName)
parseAuthSource(ctx, u, form.SourceID)
if ctx.Written() {
return
}
Expand Down

0 comments on commit dfbc530

Please sign in to comment.