Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion profiles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ def logout():
@app.route("/image/<uid>", methods=["GET"])
def image(uid):
try:
return get_image(uid)
response = get_image(uid)
if isinstance(response, str):
return redirect(response, code=302)
return response
except BadQueryError as bqe:
return render_template("404.html", message=bqe, **app.config['DATADOG_RUM_CONFIG']), 404

Expand Down
7 changes: 3 additions & 4 deletions profiles/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import ldap
import requests
from PIL import Image
from flask import redirect

from profiles import _ldap

Expand Down Expand Up @@ -414,7 +413,7 @@ def get_image(uid):
github = account.github
twitter = account.twitterName
except KeyError:
return redirect(get_gravatar(), code=302)
return get_gravatar()

# Return stored Image
if image:
Expand All @@ -425,7 +424,7 @@ def get_image(uid):
try:
with urllib.request.urlopen(url) as gravatar:
if gravatar.getcode() == 200:
return redirect(url, code=302)
return url
except urllib.error.HTTPError:
pass

Expand All @@ -448,7 +447,7 @@ def get_image(uid):
pass

# Fall back to default
return redirect(get_gravatar(), code=302)
return get_gravatar()


@lru_cache(maxsize=1024)
Expand Down
Loading