diff options
author | Galen Guyer <galen@galenguyer.com> | 2022-08-25 17:17:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 17:17:29 -0400 |
commit | 013d429ba47e774c06741f8ba7de0e8affa5e1b6 (patch) | |
tree | 5f95587ac2828ff45288707abaa6f1976700f13e | |
parent | e4414ca71d7f208d874b5ba9ca43ae2c81542ef8 (diff) | |
parent | e5761dc7d331e0b39ae9bbd6e29acd078438baeb (diff) |
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | packet/templates/include/nav.html | 4 | ||||
-rw-r--r-- | packet/utils.py | 13 |
3 files changed, 17 insertions, 2 deletions
diff --git a/package.json b/package.json index 0550e4f..1a283db 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "title": "CSH Packet", "name": "csh-packet", - "version": "3.5.6", + "version": "3.5.7", "description": "A web app implementation of the CSH introductory packet.", "bugs": { "url": "https://github.com/ComputerScienceHouse/packet/issues", diff --git a/packet/templates/include/nav.html b/packet/templates/include/nav.html index 3fd0fe9..6573b8b 100644 --- a/packet/templates/include/nav.html +++ b/packet/templates/include/nav.html @@ -41,7 +41,11 @@ <li class="navbar-user dropdown"> <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" id="user01"> + {% if info.realm == "csh" %} <img src="https://profiles.csh.rit.edu/image/{{ info.uid }}"> + {% else %} + <img src="{{ get_rit_image(info.uid) }}"> + {% endif %} {{ info.uid }} <span class="caret"></span> </a> diff --git a/packet/utils.py b/packet/utils.py index 75c9802..a6e9158 100644 --- a/packet/utils.py +++ b/packet/utils.py @@ -4,9 +4,10 @@ General utilities and decorators for supporting the Python logic from datetime import datetime, time, timedelta, date from functools import wraps, lru_cache from typing import Any, Callable, TypeVar, cast +from urllib.parse import urlparse import requests -from flask import session, redirect +from flask import session, redirect, request from packet import auth, app, db, ldap from packet.mail import send_start_packet_mail @@ -64,6 +65,16 @@ def is_freshman_on_floor(rit_username: str) -> bool: return False +@app.before_request +def before_reqest_callback() -> Any: + """ + Pre-request function to ensure we're on the right URL before OIDC sees anything + """ + if urlparse(request.base_url).hostname != app.config['SERVER_NAME']: + return redirect(request.base_url.replace(urlparse(request.base_url).hostname, + app.config['SERVER_NAME']), code=302) + return None + def packet_auth(func: WrappedFunc) -> WrappedFunc: """ Decorator for easily configuring oidc |