mirror of
https://github.com/juanfont/headscale.git
synced 2025-06-19 01:18:37 +02:00
validate email prefix as username
This commit is contained in:
parent
101b998b21
commit
3a66286c48
@ -322,9 +322,11 @@ func (u *User) FromClaim(claims *OIDCClaims) {
|
||||
|
||||
if claims.Email != "" && claims.EmailVerified {
|
||||
emailParts := strings.Split(claims.Email, "@")
|
||||
if len(emailParts) > 0 && emailParts[0] != "" {
|
||||
err = util.ValidateUsername(emailParts[0])
|
||||
if err == nil {
|
||||
u.Name = emailParts[0]
|
||||
log.Debug().Msgf("Using email prefix %s as name", u.Name)
|
||||
} else {
|
||||
log.Debug().Err(err).Msgf("Email prefix %s is not valid username", emailParts[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user