diff --git a/openlibrary/accounts/model.py b/openlibrary/accounts/model.py index b0623444c74..db98363a829 100644 --- a/openlibrary/accounts/model.py +++ b/openlibrary/accounts/model.py @@ -688,19 +688,23 @@ def create( ia_account.test = True return ia_account - elif 'screenname' not in response.get('values', {}): - error = OLAuthenticationError('undefined_error') - error.response = response - raise error - - elif attempt >= retries: + # Response has returned "failure" with reasons in "values" + failures = response.get('values', {}) + if 'screenname' not in failures: + for field in failures: + # raise the first error if multiple + # e.g. bad_email, bad_password + error = OLAuthenticationError(f'bad_{field}') + error.response = response + raise error + elif attempt < retries: + _screenname = append_random_suffix(screenname) + attempt += 1 + else: e = OLAuthenticationError('username_registered') e.value = _screenname raise e - _screenname = append_random_suffix(screenname) - attempt += 1 - @classmethod def xauth(cls, op, test=None, s3_key=None, s3_secret=None, xauth_url=None, **data): """ diff --git a/openlibrary/i18n/messages.pot b/openlibrary/i18n/messages.pot index 538ed42914b..5b9a30ff50a 100644 --- a/openlibrary/i18n/messages.pot +++ b/openlibrary/i18n/messages.pot @@ -485,12 +485,6 @@ msgstr "" msgid "OR" msgstr "" -#: login.html -msgid "" -"Please enter your Internet Archive " -"email and password to access your Open Library account." -msgstr "" - #: account/create.html login.html #, python-format msgid "You are already logged into Open Library as %(user)s." @@ -503,6 +497,12 @@ msgid "" "logout'].submit()\">log out and start the signup process afresh." msgstr "" +#: login.html +msgid "" +"Please enter your Internet Archive " +"email and password to access your Open Library account." +msgstr "" + #: forms.py login.html msgid "Email" msgstr "" @@ -7828,10 +7828,23 @@ msgid "" "or email openlibrary@archive.org for help." msgstr "" +#: account.py +msgid "Email provider not recognized." +msgstr "" + +#: account.py +msgid "Password requirements not met." +msgstr "" + #: account.py msgid "A problem occurred and we were unable to log you in" msgstr "" +#: account.py +#, python-format +msgid "Request failed with error code: %(error_code)s" +msgstr "" + #: account.py #, python-format msgid "" diff --git a/openlibrary/plugins/upstream/account.py b/openlibrary/plugins/upstream/account.py index 55b26516ae8..a4a5a7b63a5 100644 --- a/openlibrary/plugins/upstream/account.py +++ b/openlibrary/plugins/upstream/account.py @@ -93,9 +93,15 @@ def get_login_error(error_key): "request_timeout": _( "Servers are experiencing unusually high traffic, please try again later or email openlibrary@archive.org for help." ), + "bad_email": _("Email provider not recognized."), + "bad_password": _("Password requirements not met."), "undefined_error": _('A problem occurred and we were unable to log you in'), } - return LOGIN_ERRORS[error_key] + return ( + LOGIN_ERRORS[error_key] + if error_key in LOGIN_ERRORS + else _("Request failed with error code: %(error_code)s", error_code=error_key) + ) class availability(delegate.page): diff --git a/openlibrary/templates/account/create.html b/openlibrary/templates/account/create.html index 9ce793a0411..d24adfee8d9 100644 --- a/openlibrary/templates/account/create.html +++ b/openlibrary/templates/account/create.html @@ -60,7 +60,13 @@

$_("Sign Up")

$else:
$if form.note: -
$form.note
+
+ +
$def screenname_url(): $_('Your URL'): https://openlibrary.org/people/$(form.username.value or _('screenname')) diff --git a/openlibrary/templates/login.html b/openlibrary/templates/login.html index 21d9b957b41..ec9f8a372cf 100644 --- a/openlibrary/templates/login.html +++ b/openlibrary/templates/login.html @@ -29,7 +29,6 @@

$_("Log In")

$if not ctx.user: $:render_template("account/ia_thirdparty_logins")
$_('OR')
-
$:_('Please enter your Internet Archive email and password to access your Open Library account.')
$if ctx.user:

$:_("You are already logged into Open Library as %(user)s.", user='%s' % (ctx.user.key, ctx.user.displayname))

@@ -38,8 +37,14 @@

$_("Log In")

$else: $if form.note: -
$form.note
- +
+ +
+
$:_('Please enter your Internet Archive email and password to access your Open Library account.')