Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions services/auth/source/ldap/source_authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ func (source *Source) Authenticate(ctx context.Context, user *user_model.User, u
// User not in LDAP, do nothing
return nil, user_model.ErrUserNotExist{Name: loginName}
}

// Fallback.
if len(sr.Username) == 0 {
sr.Username = userName
}
if len(sr.Mail) == 0 {
sr.Mail = fmt.Sprintf("%s@localhost.local", sr.Username)
}
isAttributeSSHPublicKeySet := len(strings.TrimSpace(source.AttributeSSHPublicKey)) > 0

// Update User admin flag if exist
Expand Down Expand Up @@ -70,15 +76,6 @@ func (source *Source) Authenticate(ctx context.Context, user *user_model.User, u
}
}
} else {
// Fallback.
if len(sr.Username) == 0 {
sr.Username = userName
}

if len(sr.Mail) == 0 {
sr.Mail = fmt.Sprintf("%s@localhost.local", sr.Username)
}

user = &user_model.User{
LowerName: strings.ToLower(sr.Username),
Name: sr.Username,
Expand Down