mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix gravatar not loading after being removed from cookie. Improve gravatar loading so it changes without relogging
This commit is contained in:
parent
7e6aa8c817
commit
f37e1e04a4
@ -17,6 +17,8 @@ import threading
|
|||||||
from cron_validator import CronValidator
|
from cron_validator import CronValidator
|
||||||
#TZLocal is set as a hidden import on win pipeline
|
#TZLocal is set as a hidden import on win pipeline
|
||||||
from tzlocal import get_localzone
|
from tzlocal import get_localzone
|
||||||
|
import libgravatar
|
||||||
|
import requests
|
||||||
|
|
||||||
from tornado import locale, iostream
|
from tornado import locale, iostream
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
@ -244,6 +246,24 @@ class PanelHandler(BaseHandler):
|
|||||||
} if api_key is not None else None,
|
} if api_key is not None else None,
|
||||||
'superuser': superuser
|
'superuser': superuser
|
||||||
}
|
}
|
||||||
|
if helper.get_setting("allow_nsfw_profile_pictures"):
|
||||||
|
rating = "x"
|
||||||
|
else:
|
||||||
|
rating = "g"
|
||||||
|
|
||||||
|
|
||||||
|
#Get grvatar hash for profile pictures
|
||||||
|
if exec_user['email'] != 'default@example.com' or "":
|
||||||
|
g = libgravatar.Gravatar(libgravatar.sanitize_email(exec_user['email']))
|
||||||
|
url = g.get_image(size=80, default="404", force_default=False, rating=rating, filetype_extension=False, use_ssl=True) # + "?d=404"
|
||||||
|
if requests.head(url).status_code != 404:
|
||||||
|
profile_url = url
|
||||||
|
else:
|
||||||
|
profile_url = "/static/assets/images/faces-clipart/pic-3.png"
|
||||||
|
else:
|
||||||
|
profile_url = "/static/assets/images/faces-clipart/pic-3.png"
|
||||||
|
|
||||||
|
page_data['user_image'] = profile_url
|
||||||
|
|
||||||
if page == 'unauthorized':
|
if page == 'unauthorized':
|
||||||
template = "panel/denied.html"
|
template = "panel/denied.html"
|
||||||
|
@ -120,23 +120,6 @@ class PublicHandler(BaseHandler):
|
|||||||
# log this login
|
# log this login
|
||||||
self.controller.management.add_to_audit_log(user_data.user_id, "Logged in", 0, self.get_remote_ip())
|
self.controller.management.add_to_audit_log(user_data.user_id, "Logged in", 0, self.get_remote_ip())
|
||||||
|
|
||||||
if helper.get_setting("allow_nsfw_profile_pictures"):
|
|
||||||
rating = "x"
|
|
||||||
else:
|
|
||||||
rating = "g"
|
|
||||||
|
|
||||||
|
|
||||||
#Get grvatar hash for profile pictures
|
|
||||||
if user_data.email != 'default@example.com' or "":
|
|
||||||
g = libgravatar.Gravatar(libgravatar.sanitize_email(user_data.email))
|
|
||||||
url = g.get_image(size=80, default="404", force_default=False, rating=rating, filetype_extension=False, use_ssl=True) # + "?d=404"
|
|
||||||
if requests.head(url).status_code != 404:
|
|
||||||
profile_url = url
|
|
||||||
else:
|
|
||||||
profile_url = "/static/assets/images/faces-clipart/pic-3.png"
|
|
||||||
else:
|
|
||||||
profile_url = "/static/assets/images/faces-clipart/pic-3.png"
|
|
||||||
|
|
||||||
next_page = "/panel/dashboard"
|
next_page = "/panel/dashboard"
|
||||||
self.redirect(next_page)
|
self.redirect(next_page)
|
||||||
else:
|
else:
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
<li class="nav-item dropdown user-dropdown">
|
<li class="nav-item dropdown user-dropdown">
|
||||||
<a class="nav-link dropdown-toggle" id="UserDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" id="UserDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
|
||||||
<img class="img-xs rounded-circle profile-picture" src="{{ data['user_data'].get('profile_url') }}" alt="Profile image"> </a>
|
<img class="img-xs rounded-circle profile-picture" src="{{ data['user_image'] }}" alt="Profile image"> </a>
|
||||||
<div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="UserDropdown">
|
<div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="UserDropdown">
|
||||||
<div class="dropdown-header text-center">
|
<div class="dropdown-header text-center">
|
||||||
<img class="img-md rounded-circle profile-picture" src="{{ data['user_data'].get('profile_url') }}" alt="Profile image">
|
<img class="img-md rounded-circle profile-picture" src="{{ data['user_image'] }}" alt="Profile image">
|
||||||
<p class="mb-1 mt-3 font-weight-semibold">{{ data['user_data']['username'] }}</p>
|
<p class="mb-1 mt-3 font-weight-semibold">{{ data['user_data']['username'] }}</p>
|
||||||
<p class="font-weight-light text-muted mb-0">Roles: </p>
|
<p class="font-weight-light text-muted mb-0">Roles: </p>
|
||||||
{% for r in data['user_role'] %}
|
{% for r in data['user_role'] %}
|
||||||
|
Loading…
Reference in New Issue
Block a user