Repository: internetarchive/openlibrary

Issue:
Logging in takes you to an error page


### Evidence / Screenshot (if possible)
![image](https://github.com/internetarchive/openlibrary/assets/6251786/d32101ec-c44e-488b-a72d-92502f0aef6f)

![image](https://github.com/internetarchive/openlibrary/assets/6251786/61316d1a-6cb8-420f-a097-04ddfe3a9731)


### Relevant url?
<!-- `https://openlibrary.org/...` -->

### Steps to Reproduce
<!-- What steps caused you to find the bug? -->
1. Log in to open library

<!-- What actually happened after these steps? What did you expect to happen? -->
* Actual: An error page is shown. The log in succeeds, but it looks like it failed.
* Expected: The login succeeds normally.

### Details

- **Logged in (Y/N)?** N
- **Browser type/version?** FF119
- **Operating system?** Win10
- **Environment (prod/dev/local)?** prod
<!-- If not sure, put prod -->

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->



Discussion:

Resolving patch:
diff --git a/openlibrary/core/models.py b/openlibrary/core/models.py
--- a/openlibrary/core/models.py
+++ b/openlibrary/core/models.py
@@ -809,9 +809,6 @@ def has_cookie(self, name):
     def is_printdisabled(self):
         return web.cookies().get('pd')
 
-    def is_screener_eligible(self):
-        return web.cookies().get('se')
-
     def is_admin(self):
         return self.is_usergroup_member('/usergroup/admin')
 
diff --git a/openlibrary/plugins/upstream/account.py b/openlibrary/plugins/upstream/account.py
--- a/openlibrary/plugins/upstream/account.py
+++ b/openlibrary/plugins/upstream/account.py
@@ -25,8 +25,6 @@
 from openlibrary.core import helpers as h, lending
 from openlibrary.core.booknotes import Booknotes
 from openlibrary.core.bookshelves import Bookshelves
-from openlibrary.core.helpers import days_since
-from openlibrary.core.lending import s3_loan_api
 from openlibrary.core.observations import Observations
 from openlibrary.core.ratings import Ratings
 from openlibrary.plugins.recaptcha import recaptcha
@@ -406,10 +404,6 @@ def POST(self):
         )
         ol_account = OpenLibraryAccount.get(email=email)
 
-        # Don't overwrite the cookie, which will contain banner display preferences
-        if not web.cookies().get('se', False):
-            self.set_screener_cookie(ol_account)
-
         if ol_account and ol_account.get_user().get_safe_mode() == 'yes':
             web.setcookie('sfw', 'yes', expires=expires)
         blacklist = [
@@ -438,45 +432,6 @@ def POST_resend_verification_email(self, i):
         )
         return render.message(title, message)
 
-    def set_screener_cookie(self, account: OpenLibraryAccount):
-        if self.is_eligible_for_screener(account):
-            # `se` is "Survey eligible"
-            web.setcookie('se', '1', expires=(3600 * 24 * 30))  # Expires in 30 days
-
-    def is_eligible_for_screener(self, account: OpenLibraryAccount) -> bool:
-        # It is August 2023:
-        if (now := datetime.now()) and now.month != 9 and now.year != 2023:
-            return False
-
-        # Account must be at least 90 days old:
-        if days_since(account.creation_time()) < 90:
-            return False
-
-        # Account was created using a university's domain:
-        email = account.email
-        if not self.is_edu_domain(email):
-            return False
-
-        # Has borrowed at least three books:
-        if not self.has_borrowed_at_least(3, account.s3_keys):
-            return False
-
-        return True
-
-    def is_edu_domain(self, email: str) -> bool:
-        if not email or '@' not in email:
-            return False
-
-        domain = email.split('@')[-1]
-
-        sorted_edu_domains = utils.get_edu_domains()
-
-        return domain in sorted_edu_domains
-
-    def has_borrowed_at_least(self, amount: int, s3_keys) -> bool:
-        resp = s3_loan_api(s3_keys, action='user_borrow_history', limit=amount).json()
-        return len(resp) == amount
-
 
 class account_verify(delegate.page):
     """Verify user account."""
diff --git a/openlibrary/plugins/upstream/utils.py b/openlibrary/plugins/upstream/utils.py
--- a/openlibrary/plugins/upstream/utils.py
+++ b/openlibrary/plugins/upstream/utils.py
@@ -1313,24 +1313,6 @@ def get_location_and_publisher(loc_pub: str) -> tuple[list[str], list[str]]:
     return ([], [loc_pub.strip(STRIP_CHARS)])
 
 
-@cache.memoize(engine="memcache", key="edu_domains", expires=0)
-def get_edu_domains() -> list[str]:
-    """
-    This list created using this gist: https://gist.github.com/jimchamp/f67ef14c3bcf11593f393ee5288f6476 on
-    https://raw.githubusercontent.com/Hipo/university-domains-list/master/world_universities_and_domains.json.
-
-    See: https://github.com/internetarchive/openlibrary/issues/8180
-    """
-    p = Path(Path.cwd(), 'static', 'edu-domains.txt')
-
-    results = []
-    with p.open() as f:
-        for line in f:
-            results.append(line.strip())
-
-    return results
-
-
 def setup() -> None:
     """Do required initialization"""
     # monkey-patch get_markdown to use OL Flavored Markdown


Test patch: