def user():
    if request.method == "GET":
        return render_template("user.html")
    elif request.method == "POST":
        form = request.form
        us = form["username"]
        pas = form["password"]
        user = {"username": us, "password": pas}
        a = user_collection.find_one(user["username"])
        if a == None:
            return "This user doesn't exist. Please register a new account."
Exemple #2
0
def validate_user(user_name, password, email, length=8):
    if user_name.isalnum() == False:
        return "user name must contain alpha numeric characters"
    if password_format(password, length) == False:
        return f"password must must be at least {length} characters long \
            with at least one upper and one lower case letter, \
            at least one special character and no white spaces"

    if email_valid(email) == False:
        return "email address does not exist"
    if user_collection.find_one({'user': user_name}) != None:
        return "user name taken"
    else:
        return True
def get_by_username(username):
    u = user_collection.find_one({"username": username})
    return u
def get_by_id(id):
    u = user_collection.find_one({"_id": ObjectId(id)})
    return u
Exemple #5
0
def find_by_username(username):
    f = user_collection.find_one({"username": username})
    return f
Exemple #6
0
def find_by_password(password):
    p = user_collection.find_one({"password": password})
    return p
def find_by_username(username):
    f = user_collection.find_one(username["username"])
    return f