0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 12:44:07 +01:00

Fix empty field login_name in API response JSON when creating user (#30511)

Fix #30508

ps: if `sourceID` is not set, `LoginName` will be ignored
This commit is contained in:
yp05327 2024-04-16 14:13:00 +09:00 committed by GitHub
parent c70e442ce4
commit cf9061f44a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,7 +30,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
}
@ -47,7 +47,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
@ -83,12 +82,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
}