Merge pull request #631 from mouse-reeve/remote-server-save

Fixes bug in saving remote server
This commit is contained in:
Mouse Reeve 2021-02-22 09:49:34 -08:00 committed by GitHub
commit 20f4eb74a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -171,15 +171,15 @@ class User(OrderedCollectionPageMixin, AbstractUser):
def save(self, *args, **kwargs):
''' populate fields for new local users '''
created = not bool(self.id)
if not self.local and not re.match(regex.full_username, self.username):
# generate a username that uses the domain (webfinger format)
actor_parts = urlparse(self.remote_id)
self.username = '%s@%s' % (self.username, actor_parts.netloc)
super().save(*args, **kwargs)
return
# this user already exists, no need to populate fields
if self.id:
if not created:
super().save(*args, **kwargs)
return