-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IA-only auth flow #526
IA-only auth flow #526
Conversation
openlibrary/accounts/model.py
Outdated
# `ol_account` shares the same email as our IA account and | ||
# thus can and should be safely linked to our IA account, or | ||
# (c) no `ol_account` which is linked or can be linked has | ||
# been found and therefore, asuming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misspell. Should be "assuming".
openlibrary/accounts/model.py
Outdated
except ValueError as e: | ||
return {'error': 'max_retries_exceeded', 'msg': str(e)} | ||
|
||
if not ol_account.itemname: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under which conditions would ol_account.itemname
be true-y? We've already determined that there was no ol_account
going in to this branch, and OpenLibraryAccount.create()
will return an error dictionary if it fails, won't it? (Or is there a case where it will return None
?) Cuz if what I say is correct, then seems like if not ol_account.itemname
will always be true, since it's always dealing with a newly created, therefore unlinked ol_account
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, there shouldn't be a case possible, I added this because a function had been removed between branches causing it to appear as if the account did not have an itemname set after login (when really the function to fetch the itemname was indeed the problem)
openlibrary/accounts/model.py
Outdated
if not ol_account.verified: | ||
return {'error': 'account_not_verified'} | ||
if lending.config_ia_auth_only: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can slightly simplify the logic by consolidating this if
with the occurrence of if lending.config_ia_auth_only
just above. If you go that route, you'll need to move around the if not ol_account.verified
logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is about the same level of complexity in either case as ol_account.verified
would then have to be checked in 2 locations instead of lending.config_ia_auth_only
openlibrary/accounts/model.py
Outdated
# call to safely activate them. | ||
ol_account.activate() | ||
else: | ||
return {'error': 'ia_account_not_verified'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, wouldn't it be the OL account which is not verified (for dev usage)? (Of course, this logic may shift if you follow the previous suggestion.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right
openlibrary/accounts/model.py
Outdated
# call to safely activate them. | ||
ol_account.activate() | ||
else: | ||
return {'error': 'ia_account_not_verified'} | ||
if ol_account.blocked: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add comment. This is for the new OL account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e. We already checked for blocked accounts up above, but you might comment that this is for the newly fetched OL account.
openlibrary/accounts/model.py
Outdated
# When enabled, this will prevent users from logging in | ||
# with their Open Library credentials and instead require | ||
# Internet Archive (Archive.org) credentials. | ||
return {'error': 'ia_login_only'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wait this long to shut out OL logins when in production? In this current code, if the IA login fails, then the system still makes a db call to OL and an HTTP call to IA and then realizes "Oh, hey, I'm in production. I should return an error." Seems these should be moved up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this flow entirely to simplify path of execution
openlibrary/accounts/model.py
Outdated
@@ -681,13 +736,15 @@ def audit_accounts(email, password, test=False): | |||
ol_account.link(audit['link']) | |||
stats.increment('ol.account.xauth.auto-linked') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this whole branch starting with # Links the accounts if they can be and are not already
is not needed for the production case. Haven't we already hit every case up above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was an attempt to fix the problem where user logged in and it appeared as if they were not linked (when really the function to check link status had a regression). Resolved
@@ -23,7 +23,7 @@ | |||
<p>If you can't find the email, just hit this button to send a fresh one:</p> | |||
|
|||
<form method="POST" class="olform"> | |||
<input type="hidden" name="username" value="$username"/> | |||
<input type="hidden" name="email" value="$email"/> | |||
<input type="hidden" name="password" value="$password"/> | |||
<input type="hidden" name="action" value="resend_verification_email"/> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure all these forms are in the test plan.
da056e0
to
866cfca
Compare
LGTM |
72b5f1a
to
fce7901
Compare
@mekarpeles Did this change not disable the user's ability to set preferences, such as interface language? I can't even find the menu anymore. |
Note: Before accepting, we need to CR and checkin code into olsystem
Todo:
Test flows:
Account Creation
Login