Skip to content

Commit

Permalink
Fixes #17279: Do not regenerate key when updating a token via REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Aug 28, 2024
1 parent cac9235 commit ea889e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion netbox/users/api/serializers_/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Meta:
brief_fields = ('id', 'url', 'display', 'key', 'write_enabled', 'description')

def to_internal_value(self, data):
if 'key' not in data:
if not getattr(self.instance, 'key', None) and 'key' not in data:
data['key'] = Token.generate_key()
return super().to_internal_value(data)

Expand Down

0 comments on commit ea889e9

Please sign in to comment.