Skip to content

Commit

Permalink
change invite code encoding from ascii to utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Nov 8, 2023
1 parent 722c64e commit 6564ce4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions ephios/plugins/federation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ class RedeemInviteCodeForm(forms.Form):

def clean_code(self):
try:
data = json.loads(
base64.b64decode(self.cleaned_data["code"].encode("ascii")).decode("ascii")
)
data = json.loads(base64.b64decode(self.cleaned_data["code"].encode()).decode())
if settings.GET_SITE_URL() != data["guest_url"]:
raise ValidationError(_("This invite code is not issued for this instance."))
except (binascii.Error, JSONDecodeError, KeyError) as exc:
Expand Down
4 changes: 2 additions & 2 deletions ephios/plugins/federation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def get_share_string(self):
return base64.b64encode(
json.dumps(
{"guest_url": self.url, "code": self.code, "host_url": settings.GET_SITE_URL()}
).encode("ascii")
).decode("ascii")
).encode()
).decode()

class Meta:
verbose_name = _("invite code")
Expand Down

0 comments on commit 6564ce4

Please sign in to comment.