Skip to content

Commit

Permalink
Switch validation function to static method
Browse files Browse the repository at this point in the history
  • Loading branch information
rebecca-shoptaw committed May 8, 2024
1 parent 0beb6ed commit 1ce2c64
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions openlibrary/plugins/upstream/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ def GET(self):
class account_validation(delegate.page):
path = '/account/validate'

@staticmethod
def ia_username_exists(username):
url = "https://archive.org/metadata/@%s" % username
try:
Expand All @@ -563,7 +564,7 @@ def ia_username_exists(username):
return

@staticmethod
def validate_username(self, username):
def validate_username(username):
if not 3 <= len(username) <= 20:
return _('Username must be between 3-20 characters')
if not re.match('^[A-Za-z0-9-_]{3,20}$', username):
Expand All @@ -573,7 +574,7 @@ def validate_username(self, username):
if ol_account:
return _("Username unavailable")

ia_account = self.ia_username_exists(username)
ia_account = account_validation.ia_username_exists(username)
if ia_account:
return _("An Internet Archive account already exists with this username")

Expand Down

0 comments on commit 1ce2c64

Please sign in to comment.