Normalize nickname before saving to database

This commit is contained in:
bravechamp 2022-03-13 21:55:36 +00:00
parent 9901d6b2e7
commit 60ee04674d

View File

@ -370,7 +370,21 @@ func (h *Headscale) ExpireMachine(machine *Machine) {
// RenameMachine takes a Machine struct and sets the expire field to now.
func (h *Headscale) RenameMachine(machine *Machine, newName string) {
machine.Nickname = newName
newNickname, err := NormalizeToFQDNRules(
newName,
h.cfg.OIDC.StripEmaildomain,
)
if err != nil {
log.Error().
Caller().
Str("func", "RenameMachine").
Str("machine", machine.Name).
Str("newName", newName).
Err(err)
return
}
machine.Nickname = newNickname
h.setLastStateChangeToNow(machine.Namespace.Name)