def go(Admin, Password): """ Takes as inputs the Admin username and password and creates the users table in the database Creates the configuration file that specifies project paths :calls: setup.py :param Admin: :param Password: :return: """ file = open('CONFIG.txt', 'a') file.close() from TheBeets.conf import Config manager = Config() manager.setup_main_db() manager.set_users_db() from TheBeets.conf import load_in settings = load_in() conn = sqlite3.connect(settings['MAIN_DB']) conn.execute("CREATE TABLE IF NOT EXISTS {tn} (id INTEGER," "email TEXT," "email_verified INTEGER," "username TEXT," "password TEXT," "logged_in INTEGER, " "first_name TEXT," "last_name TEXT," "active INTEGER," "reset_request INTEGER," "is_authenticated INTEGER," "PRIMARY KEY (username))".format(tn='users')) conn.commit() conn.execute("""INSERT INTO users VALUES ('{id}', '{email}', '{email_verified}', '{username}', '{password}', {logged_in}, '{first_name}', '{last_name}', {active}, {reset_request}, {is_authenticated})""".format( id=1, email='*****@*****.**', email_verified=1, username=Admin, password=make_password(Password), logged_in=1, first_name="", last_name="", active=1, reset_request=0, is_authenticated=0)) conn.commit() conn.close() from TheBeets.Manager._FileController import FileController FileController().file_handler(Admin)
from flask import Flask, session, redirect, request, Response import sqlite3 # from crypotgraphy import Fernet, MultiFernet import random from TheBeets.conf import load_in settings = load_in() app = Flask(__name__) app.secret_key = bytes(random.getrandbits(16)) ######################################################################################################################## # SESSION CONFIGURATION ######################################################################################################################## def login_required(): """ Checks the cookie data to see if the session is new or if the user has already authenticated """ if session['counter'] < 2: session.clear() return True def sumsessioncounter(): """ Sums the session counter upon new page request to keep user signed in """ try: session['counter'] += 1 except KeyError: