mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Github ha dei cookie session? Wtf?
This commit is contained in:
parent
1b2abfefdf
commit
7e2c355edf
3 changed files with 11 additions and 6 deletions
2
db.py
2
db.py
|
@ -139,7 +139,7 @@ class Royal(Base, Mini):
|
|||
if self.email is None:
|
||||
return f"https://www.gravatar.com/avatar/{libgravatar.md5_hash(self.username)}?d=identicon&f=y"
|
||||
gravatar = libgravatar.Gravatar(self.email)
|
||||
return gravatar.get_image(default="identicon")
|
||||
return gravatar.get_image(default="identicon", use_ssl=True)
|
||||
|
||||
@classmethod
|
||||
def mini_get_single_from_royal(cls, session: Session, royal: "Royal"):
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<span id="debug-mode">DEBUG MODE</span>
|
||||
{% endif %}
|
||||
<span class="login-status">
|
||||
{% if g.user is not none %}
|
||||
{% if g.user %}
|
||||
<img src="{{ g.user.get_gravatar_url() }}" class="gravatar">
|
||||
<a href="{{ url_for('page_profile', name=g.user.username) }}">{{ g.user.username }}</a>
|
||||
<a class="btn" href="{{ url_for('page_logout') }}">Logout</a>
|
||||
|
|
13
webserver.py
13
webserver.py
|
@ -1,4 +1,3 @@
|
|||
import secrets
|
||||
from flask import Flask, render_template, request, abort, redirect, url_for, Markup, escape, jsonify
|
||||
from flask import session as fl_session
|
||||
from flask import g as fl_g
|
||||
|
@ -9,6 +8,7 @@ import markdown2
|
|||
import datetime
|
||||
# noinspection PyPackageRequirements
|
||||
import telegram
|
||||
import errors
|
||||
import query_discord_music
|
||||
import random
|
||||
import re
|
||||
|
@ -115,9 +115,14 @@ def page_profile(name: str):
|
|||
css = fl_g.session.query(db.ProfileData).filter_by(royal=user).one_or_none()
|
||||
mini_data = []
|
||||
for game in db.mini_list:
|
||||
data = game.mini_get_single_from_royal(fl_g.session, user)
|
||||
try:
|
||||
data = game.mini_get_single_from_royal(fl_g.session, user)
|
||||
except errors.NotFoundError():
|
||||
data = None
|
||||
# TODO: investigate on why instrumentedlists are returned
|
||||
if isinstance(data, InstrumentedList):
|
||||
if data is None:
|
||||
continue
|
||||
elif isinstance(data, InstrumentedList):
|
||||
mini_data.append({
|
||||
"name": game._mini_name,
|
||||
"data": data[0]
|
||||
|
@ -367,7 +372,7 @@ def pre_request():
|
|||
fl_g.css = "nryg.less"
|
||||
fl_g.rygconf = config
|
||||
fl_g.session = db.Session()
|
||||
if fl_session is None:
|
||||
if fl_session:
|
||||
fl_g.user = None
|
||||
else:
|
||||
fl_g.user = fl_g.session.query(db.Royal).filter_by(id=fl_session["user_id"]).one_or_none()
|
||||
|
|
Loading…
Reference in a new issue