Ejemplo n.º 1
0
def decorator():
    _project = request.query.proj
    print("get_project", _project)
    if not _project or _project not in PROJECTS:
        _project = request.urlparts.hostname.split('.')
        if _project and (_project[0] in PROJECTS):
            _project = _project[0]
        elif request.get_cookie('_spy_project_') in PROJECTS:
            _project = request.get_cookie('_spy_project_')
        else:
            _project = "superpython"
    return _project
Ejemplo n.º 2
0
def decorator():
    _project = request.query.proj
    print("get_project", _project)
    if not _project or _project not in PROJECTS:
        _project = request.urlparts.hostname.split('.')
        if _project and (_project[0] in PROJECTS):
            _project = _project[0]
        elif request.get_cookie('_spy_project_') in PROJECTS:
            _project = request.get_cookie('_spy_project_')
        else:
            _project = "superpython"
    return _project
Ejemplo n.º 3
0
def show__page_about():

    # Connect to the database.
    conn = sqlite3.connect(config["paths"]["file_auth_database"])
    c = conn.cursor()
    c.execute("SELECT SessionID FROM secure_login")
    rows = c.fetchall()

    for row in rows:
        for col in row:
            username = request.get_cookie("username", secret=col)
            if username != None:
                # Delete cookie
                response.delete_cookie("username", secret=col)
                c.execute("UPDATE secure_login SET SessionID = (?) WHERE Username = (?)", (None, str(username),))
                c.close()
                response.status = 303
                response.set_header('Location', '/')
                break
            else:
                pass
    c.close()

    # Now redirect the user back to the correct page.
    response.status = 303
    response.set_header('Location', '/')
Ejemplo n.º 4
0
    def decorator():
        _project = request.query.proj
        print("get_project", _project)
        if not _project or _project not in PROJECTS:
            _project = request.urlparts.hostname.split('.')
            if _project and (_project[0] in PROJECTS):
                _project = _project[0]
            elif request.get_cookie('_spy_project_') in PROJECTS:
                _project = request.get_cookie('_spy_project_')
            else:
                _project = "superpython"

        my_globals = {}
        my_globals.update(globals())
        my_globals['project'] = _project
        call_fn = types.FunctionType(func.func_code, my_globals)
        return call_fn()
Ejemplo n.º 5
0
 def _check_cookie(self):
     session_id = request.get_cookie('session_id')
     if session_id:
         self.user = self.db_engine.validate_session(session_id)
         if self.user:
             response.set_cookie(
                 'session_id',
                 session_id,
                 expires=datetime.now() + timedelta(
                     days=int(self.web_settings['session_expire_days'])))
Ejemplo n.º 6
0
    def check_credentials(**kwargs):

        # Connect to the database.
        conn = sqlite3.connect(config["paths"]["file_auth_database"])
        c = conn.cursor()
        c.execute("SELECT SessionID FROM secure_login")
        rows = c.fetchall()
        c.close()

        for row in rows:
            for col in row:
                username = request.get_cookie("username", secret=col)
                if username != None:
                    return fn(**kwargs)
                    break
                else:
                    pass
        abort(401)
Ejemplo n.º 7
0
def get_cookie(name):
    return request.get_cookie(name, secret=SECRET_KEY)
Ejemplo n.º 8
0
def getPlayCodeFromCookie():
    return request.get_cookie("playlist", secret=SECRET_KEY)
Ejemplo n.º 9
0
def getUidFromCookie():
    return request.get_cookie(UID, secret=SECRET_KEY)
Ejemplo n.º 10
0
def get_cookie_user_id():
    user_id = request.get_cookie("auth", secret=COOKIE_SECRET)
    return user_id