From 7f8e792402b66dbb4a721be4f44306d528931b86 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 16 Nov 2022 23:10:55 -0700 Subject: Force username to lowercase for now --- users/models/identity.py | 3 +++ users/views/identity.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/users/models/identity.py b/users/models/identity.py index ba8559b..4bbaeaf 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -134,6 +134,7 @@ class Identity(StatorModel): def by_username_and_domain(cls, username, domain, fetch=False, local=False): if username.startswith("@"): raise ValueError("Username must not start with @") + username = username.lower() try: if local: return cls.objects.get(username=username, domain_id=domain, local=True) @@ -281,6 +282,8 @@ class Identity(StatorModel): self.username = document.get("preferredUsername") if self.username and "@value" in self.username: self.username = self.username["@value"] + if self.username: + self.username = self.username.lower() self.manually_approves_followers = document.get( "as:manuallyApprovesFollowers" ) diff --git a/users/views/identity.py b/users/views/identity.py index b9298b7..b83ba9a 100644 --- a/users/views/identity.py +++ b/users/views/identity.py @@ -147,7 +147,7 @@ class CreateIdentity(FormView): domain_instance = Domain.get_domain(domain) new_identity = Identity.objects.create( actor_uri=f"https://{domain_instance.uri_domain}/@{username}@{domain}/actor/", - username=username, + username=username.lower(), domain_id=domain, name=form.cleaned_data["name"], local=True, -- cgit v1.2.3