-
-
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
Fix login json SFW #7935
Fix login json SFW #7935
Conversation
fix json login sfw
if audit.get('ia_email'): | ||
ol_account = OpenLibraryAccount.get(email=audit['ia_email']) | ||
if ol_account and ol_account.get_user().get_safe_mode() == 'yes': | ||
web.setcookie('sfw', 'yes', expires=expires) |
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.
Get ia_email
once, not twice...
if audit.get('ia_email'): | |
ol_account = OpenLibraryAccount.get(email=audit['ia_email']) | |
if ol_account and ol_account.get_user().get_safe_mode() == 'yes': | |
web.setcookie('sfw', 'yes', expires=expires) | |
if ( | |
ia_email := audit.get('ia_email') | |
and ol_account := OpenLibraryAccount.get(email=ia_email) | |
and ol_account.get_user().get_safe_mode() == 'yes' | |
): | |
web.setcookie('sfw', 'yes', expires=expires) |
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.
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.
Today I Learned: You need an extra sent of parens around the ia_email := audit.get('ia_email')
bit just to make it work properly! Thanks @mekarpeles
Fixes a case where for login json endpoint
ol_account
was being fetched using an empty email as opposed to the email matched by theaudit
.