Skip to content

Commit

Permalink
Normalize nickname before saving to database
Browse files Browse the repository at this point in the history
  • Loading branch information
bravechamp committed Mar 13, 2022
1 parent 9901d6b commit 60ee046
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 60ee046

Please sign in to comment.