From 01b6fc76999caf636b065d6c4b6ad552ea32cfcb Mon Sep 17 00:00:00 2001 From: Jeremy Smart Date: Tue, 16 Sep 2025 13:20:27 -0400 Subject: [PATCH 1/2] chom --- conditional/util/context_processors.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/conditional/util/context_processors.py b/conditional/util/context_processors.py index b26492ff..58adfdaa 100644 --- a/conditional/util/context_processors.py +++ b/conditional/util/context_processors.py @@ -1,5 +1,8 @@ # pylint: disable=bare-except +import hashlib +import urllib + from conditional import app from conditional.models.models import FreshmanAccount from conditional.util.cache import service_cache @@ -31,11 +34,31 @@ def check_current_student(username): return ldap_is_current_student(member) +@service_cache(maxsize=256) +def get_rit_image(username: str) -> str: + if username: + addresses = [username + "@rit.edu", username + "@g.rit.edu"] + for addr in addresses: + url = ( + "https://gravatar.com/avatar/" + + hashlib.md5(addr.encode("utf8")).hexdigest() + + ".jpg?d=404&s=250" + ) + try: + with urllib.request.urlopen(url) as gravatar: + if gravatar.getcode() == 200: + return url + except: + continue + return "https://www.gravatar.com/avatar/freshmen?d=mp&f=y" + + @app.context_processor def utility_processor(): return { "get_csh_name": get_csh_name, "get_freshman_name": get_freshman_name, + "get_rit_image": get_rit_image, "get_member_name": get_member_name, "check_current_student": check_current_student, } From 6d5a6c2b86080a6f6bb7255fcae8f561764c366a Mon Sep 17 00:00:00 2001 From: Jeremy Smart Date: Tue, 16 Sep 2025 13:37:14 -0400 Subject: [PATCH 2/2] chom --- conditional/blueprints/packet.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/conditional/blueprints/packet.py b/conditional/blueprints/packet.py index 2b40f78c..3a2a5337 100644 --- a/conditional/blueprints/packet.py +++ b/conditional/blueprints/packet.py @@ -435,3 +435,9 @@ def csh_login(): def frosh_login(): session["provider"] = "frosh" return redirect("/packet", code=301) + + +@packet_bp.route("/logout") +@auth.oidc_logout +def logout(): + return redirect("/", 302)