mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +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:
|
if self.email is None:
|
||||||
return f"https://www.gravatar.com/avatar/{libgravatar.md5_hash(self.username)}?d=identicon&f=y"
|
return f"https://www.gravatar.com/avatar/{libgravatar.md5_hash(self.username)}?d=identicon&f=y"
|
||||||
gravatar = libgravatar.Gravatar(self.email)
|
gravatar = libgravatar.Gravatar(self.email)
|
||||||
return gravatar.get_image(default="identicon")
|
return gravatar.get_image(default="identicon", use_ssl=True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mini_get_single_from_royal(cls, session: Session, royal: "Royal"):
|
def mini_get_single_from_royal(cls, session: Session, royal: "Royal"):
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<span id="debug-mode">DEBUG MODE</span>
|
<span id="debug-mode">DEBUG MODE</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="login-status">
|
<span class="login-status">
|
||||||
{% if g.user is not none %}
|
{% if g.user %}
|
||||||
<img src="{{ g.user.get_gravatar_url() }}" class="gravatar">
|
<img src="{{ g.user.get_gravatar_url() }}" class="gravatar">
|
||||||
<a href="{{ url_for('page_profile', name=g.user.username) }}">{{ g.user.username }}</a>
|
<a href="{{ url_for('page_profile', name=g.user.username) }}">{{ g.user.username }}</a>
|
||||||
<a class="btn" href="{{ url_for('page_logout') }}">Logout</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 Flask, render_template, request, abort, redirect, url_for, Markup, escape, jsonify
|
||||||
from flask import session as fl_session
|
from flask import session as fl_session
|
||||||
from flask import g as fl_g
|
from flask import g as fl_g
|
||||||
|
@ -9,6 +8,7 @@ import markdown2
|
||||||
import datetime
|
import datetime
|
||||||
# noinspection PyPackageRequirements
|
# noinspection PyPackageRequirements
|
||||||
import telegram
|
import telegram
|
||||||
|
import errors
|
||||||
import query_discord_music
|
import query_discord_music
|
||||||
import random
|
import random
|
||||||
import re
|
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()
|
css = fl_g.session.query(db.ProfileData).filter_by(royal=user).one_or_none()
|
||||||
mini_data = []
|
mini_data = []
|
||||||
for game in db.mini_list:
|
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
|
# TODO: investigate on why instrumentedlists are returned
|
||||||
if isinstance(data, InstrumentedList):
|
if data is None:
|
||||||
|
continue
|
||||||
|
elif isinstance(data, InstrumentedList):
|
||||||
mini_data.append({
|
mini_data.append({
|
||||||
"name": game._mini_name,
|
"name": game._mini_name,
|
||||||
"data": data[0]
|
"data": data[0]
|
||||||
|
@ -367,7 +372,7 @@ def pre_request():
|
||||||
fl_g.css = "nryg.less"
|
fl_g.css = "nryg.less"
|
||||||
fl_g.rygconf = config
|
fl_g.rygconf = config
|
||||||
fl_g.session = db.Session()
|
fl_g.session = db.Session()
|
||||||
if fl_session is None:
|
if fl_session:
|
||||||
fl_g.user = None
|
fl_g.user = None
|
||||||
else:
|
else:
|
||||||
fl_g.user = fl_g.session.query(db.Royal).filter_by(id=fl_session["user_id"]).one_or_none()
|
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