from flask import render_template, request, make_response, redirect
import database, re, bcrypt, secrets, time
from auth import get_session

from app import app

@app.route("/u/<username>")
def userpage(username):
    return "Page of " + username

@app.route("/user/info")
def userinfo():
    sessioninfo = get_session(request)

    if not sessioninfo:
        return "Melde dich an, um Einstellungen zu ändern!"

    uid = sessioninfo[0]

    userdata = database.fetch("SELECT created_at, last_login, username FROM user WHERE uid=?", [uid])[0]

    return render_template("user/userinfo.html", username=userdata[2], uid=uid, created_at=userdata[0])


@app.route("/user/delete")
def userdelete():
    return render_template("user/delete.html")
