Пример #1
0
def ShowChoiceMenu(input, uuid):
    # haal info op van de gebruiker
    if input == "pers_info":
        sqlconn, sqlcursor = sqlconnection.InitializeSQL()
        return sqlconnection.GetRow(sqlcursor, {"uuid": uuid})

    # haal alle info op uit de DB
    if input == "gen_info":
        sqlconn, sqlcursor = sqlconnection.InitializeSQL()
        return len(sqlconnection.GetAllRows(sqlcursor))
Пример #2
0
def Authorize(authcode, uuid):
    sqlconn, sqlcursor = sqlconnection.InitializeSQL()

    if authcode == GetTOTP(sqlconnection.GetRow(sqlcursor, {"uuid": uuid})[3]):
        return True
    else:
        return False
Пример #3
0
def AttemptLogin(username, password):
    sqlconn, sqlcursor = sqlconnection.InitializeSQL()
    stallingData = sqlconnection.GetAllRows(sqlcursor)

    # Maak een lijst van alle users, om later mee te checken
    users = []
    accounts = []
    account_uuid = None
    account_password = None

    # Voer gebruikersnaam in en test of deze voorkomt
    for row in stallingData:
        users.append(row[1])
        accounts.append([row[0], row[1], row[2]])

    if username not in users:
        return False, "username"

    # Voer wachtwoord in en check of deze voorkomt
    for account in accounts:
        if account[1] == username:
            account_uuid = account[0]
            account_password = account[2]

    if account_password != password:
        return False, "password"

    if username in users and account_password == password:
        return True, account_uuid
Пример #4
0
def ParkBike(uuid):
    sqlconn, sqlcursor = sqlconnection.InitializeSQL()

    today = datetime.datetime.now()
    storagedate = today.strftime('%d-%m-%Y, %H:%M')
    userInfo = sqlconnection.GetRow(sqlcursor, {"uuid": uuid})

    # Controleer of de fiets al gestald is of niet, en sla de nieuwe data op
    if userInfo[4] != 1:
        dataobject = {"storagestate": "1", "storagedate": storagedate}
        sqlconnection.UpdateRow(sqlconn, sqlcursor, dataobject, {"uuid": uuid})
        return True, 'Uw fiets is gestald.'
    else:
        return False, 'Uw fiets staat nog in de stalling'
Пример #5
0
def RetrieveBike(uuid):
    sqlconn, sqlcursor = sqlconnection.InitializeSQL()
    storagedate = ""

    # haal user info op
    userInfo = sqlconnection.GetRow(sqlcursor, {"uuid": uuid})

    # Pas data aan, en sla deze op, indien de fiets daadwerkelijk in de stalling staat
    if userInfo[4] != 0:
        dataobject = {"storagestate": "0", "storagedate": storagedate}
        sqlconnection.UpdateRow(sqlconn, sqlcursor, dataobject, {"uuid": uuid})
        return True, 'U kunt uw fiets ophalen.'
    else:
        return False, 'Uw fiets staat nog niet in de stalling.'
Пример #6
0
def AttemptRegister(username, password):

    sqlconn, sqlcursor = sqlconnection.InitializeSQL()
    stallingData = sqlconnection.GetAllRows(sqlcursor)

    # Maak een list van alle gebruikers
    users = []
    errormessage = None

    usernameCleared = True
    passwordCleared = True

    for row in stallingData:
        users.append(row[1])

    # Maak een username
    try:
        if username in users:
            errormessage = 'Deze gebruikersnaam is al in gebruik\nkies a.u.b. een nieuwe.'
            usernameCleared = False
        if len(username) == 0:
            errormessage = 'U heeft geen gebruikersnaam ingevoerd\nProbeer het nogmaals.'
            usernameCleared = False
        if len(username) > 24:
            errormessage = 'De gebruikersnaam mag maximaal\n24 karakters lang zijn\nProbeer het nogmaals.'
            usernameCleared = False
    except:
        errormessage = 'Ongeldige gebruikersnaam opgegeven\nprobeer nogmaals.'
        usernameCleared = False

    # Maak een wachtwoord
    if len(password) <= 0:
        errormessage = 'Ongeldig wachtwoord opgegeven\nprobeer het nogmaals.'
        passwordCleared = False

    # Als username en wachtwoord zijn aangemaakt, data opslaan
    if usernameCleared and passwordCleared:

        dataobject = { "username" : username, "password" : password, "secret" : twostep.GetSecret(), "storagestate" : "0", "storagedate" : "" }
        sqlconnection.CreateNewRow(sqlconn, sqlcursor, dataobject)

        return True, 'Het account\n{}\nis succesvol aangemaakt'.format(username)
    else:
        return False, errormessage
Пример #7
0
    def onSubmit():
        username = entry1.get()
        password = entry2.get()

        result, data = login.AttemptLogin(username, password)

        if not result:
            if data == "username":
                PopupWindow("Gebruikersnaam is onbekend")
            elif data == "password":
                PopupWindow("Wachtwoord is onbekend")
        elif result:
            global uuid
            uuid = data

            close()
            root.withdraw()

            sqlconn, sqlcursor = sqlconnection.InitializeSQL()
            ShowMainMenu(sqlconnection.GetRow(sqlcursor, {"uuid": data})[1])
Пример #8
0
    def onSubmit():
        username = entry1.get()
        password = entry2.get()

        result, data = register.AttemptRegister(username, password)

        if not result:
            PopupWindow(data)
        elif result:
            sqlconn, sqlcursor = sqlconnection.InitializeSQL()
            userData = sqlconnection.GetRow(sqlcursor, {"username": username})
            twostep.CreateAuthenticatorQRCode(userData[3], userData[1])
            AfterRegisterWindow(
                "Scan de QR Code met de\nGoogle Authenticator app")

            result, data = login.AttemptLogin(username, password)
            if result:
                global uuid
                uuid = data
                close()
                root.withdraw()

                ShowMainMenu(userData[1])