import os
from flask import Blueprint, render_template, request, jsonify, redirect, url_for

class Account:
    message:str
    rows:int

    def Authorized():
        if 'Authorization' in request.headers:
            token = request.headers['Authorization']
            if "Akademy.mA" in token:
                return True

        error = "Unauthorized ? from "+Account.getClientUrl()
        setattr(Account, "message", error)
        return False
    
    def getClientUrl():
        #Gets the URL of the client form from which the script was executed.
        url = os.getenv('HTTP_REFERER')
        if url is not None:
            return url
        else: 
            url = os.getenv('REQUEST_URI')
            if url is not None:
                return url        
        return "?"