mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-20 19:09:07 +01:00
Normalize nickname before saving to database
This commit is contained in:
parent
9901d6b2e7
commit
60ee04674d
16
machine.go
16
machine.go
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user