Beispiel #1
0
def validate(u, p):
    request_data = request.form
    credentials = Reader.getCsvDict('./data/credentials.txt')
    if request_data['user'] in credentials and request_data['user'] != '':
        if request_data['pswd'] == credentials[request_data['user']][0]:
            return True
        else:
            return False
    else:
        return False
Beispiel #2
0
def validate(u,p):
    request_data=request.form
    credentials=Reader.getCsvDict('./data/credentials.txt')
    if request_data['user'] in credentials and request_data['user']!='':
        if request_data['pswd']==credentials[request_data['user']][0]:
            return True
        else:
            return False
    else:
        return False
Beispiel #3
0
def log_in():
    if request.method=="GET":
        return render_template('form.html', title='login')                        
    elif request.method=="POST":#Verifies the username and password against constants at the top
        request_data=request.form#Takes the immutable dictionary of the user's inputs and saves it in a variable
        credentials=Reader.getCsvDict('./data/credentials.txt')
        if validate(request_data['user'],request_data['pswd']):
            return render_template('form.html', title='login', error='Successful login')
        else:
            return render_template('form.html', error='Invalid username or password', title='Login')
    else:
        return 'yo'
Beispiel #4
0
def log_in():
    if request.method == "GET":
        return render_template("form.html", title="login")
    elif request.method == "POST":  # Verifies the username and password against constants at the top
        request_data = request.form  # Takes the immutable dictionary of the user's inputs and saves it in a variable
        credentials = Reader.getCsvDict("./data/credentials.txt")
        if request_data["user"] in credentials and request_data["user"] != "":
            if request_data["pswd"] == credentials[request_data["user"]][0]:
                return "success"
            else:
                return render_template("form.html", error="Invalid username or password", title="Login")
        else:
            return render_template("form.html", error="Invalid username or password", title="Login")
    else:
        return "yo"
Beispiel #5
0
def log_in():
    if request.method == "GET":
        return render_template('form.html', title='login')
    elif request.method == "POST":  #Verifies the username and password against constants at the top
        request_data = request.form  #Takes the immutable dictionary of the user's inputs and saves it in a variable
        credentials = Reader.getCsvDict('./data/credentials.txt')
        if validate(request_data['user'], request_data['pswd']):
            return render_template('form.html',
                                   title='login',
                                   error='Successful login')
        else:
            return render_template('form.html',
                                   error='Invalid username or password',
                                   title='Login')
    else:
        return 'yo'