IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Verified Commit a49816d2 authored by Emi Simpson's avatar Emi Simpson
Browse files

Automatically redirect from the login page when logged in

parent 5555952b
......@@ -2,12 +2,13 @@ from argon2.exceptions import VerifyMismatchError
from pymysql.err import IntegrityError
from werkzeug.exceptions import abort
from werkzeug.utils import redirect
from mystic.config import get_database
from werkzeug.wrappers.response import Response
from mystic.config import get_auth_module, get_database
from flask.blueprints import Blueprint
from flask.helpers import flash
from flask.templating import render_template
from mystic.database import User
from typing import Optional, Tuple, cast
from typing import Optional, Tuple, Union, cast
from argon2 import PasswordHasher
from pymysql.cursors import Cursor
......@@ -20,7 +21,11 @@ password_hasher = PasswordHasher(memory_cost = 2097152) # 2 GiB
bp = Blueprint("direct_login", __name__, url_prefix="/")
@bp.get("/login")
def login() -> str:
def login() -> Union[str, Response]:
db = get_database()
with db.cursor() as c:
if get_auth_module().check_user(c):
return redirect('/')
return render_template("login.html",
login=("Login", "#")
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment