From 63047eb124394b723f80a307237ad8ba7e9bfbe3 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 9 Jun 2019 18:32:14 +0200 Subject: [PATCH] Test fix for telegram login --- royalnet/__init__.py | 2 +- royalnet/web/blueprints/tglogin/__init__.py | 7 +++++-- .../tglogin/templates/tglogin_success.html | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 royalnet/web/blueprints/tglogin/templates/tglogin_success.html diff --git a/royalnet/__init__.py b/royalnet/__init__.py index 9a404b18..c8ee0950 100644 --- a/royalnet/__init__.py +++ b/royalnet/__init__.py @@ -1,5 +1,5 @@ from . import audio, bots, commands, database, network, utils, error, web -version = "5.0a16" +version = "5.0a17" __all__ = ["audio", "bots", "commands", "database", "network", "utils", "error", "web"] diff --git a/royalnet/web/blueprints/tglogin/__init__.py b/royalnet/web/blueprints/tglogin/__init__.py index c7aa280d..bdc393da 100644 --- a/royalnet/web/blueprints/tglogin/__init__.py +++ b/royalnet/web/blueprints/tglogin/__init__.py @@ -1,6 +1,7 @@ import flask as f import hashlib import hmac +import datetime from ... import Royalprint from ....database.tables import Royal, Telegram @@ -31,5 +32,7 @@ def tglogin_done(): if tg_user is None: return "No such telegram", 404 royal_user = tg_user.royal - f.session["royal_id"] = royal_user.id - return f.redirect(f.url_for("/")) + f.session["login_id"] = royal_user.id + f.session["login_name"] = royal_user.name + f.session["login_date"] = datetime.datetime.now() + return f.render_template("tglogin_success.html") diff --git a/royalnet/web/blueprints/tglogin/templates/tglogin_success.html b/royalnet/web/blueprints/tglogin/templates/tglogin_success.html new file mode 100644 index 00000000..3dbabb48 --- /dev/null +++ b/royalnet/web/blueprints/tglogin/templates/tglogin_success.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% block title %} + Login with Telegram +{% endblock %} + +{% block content %} +
+
+ + Telegram login + +
+
+ Login riuscito! Sei connesso come {{ session["login_name"] }}! +
+
+{% endblock %}