bughunting for /login
This commit is contained in:
+23
-14
@@ -8,26 +8,35 @@ config = {
|
||||
"password": "pass",
|
||||
"server": "localhost:27017",
|
||||
}
|
||||
connector = "mongodb://{}:{}@{}".format(config["username"],config["password"], config["server"]
|
||||
connector = "mongodb://{}:{}@{}".format(config["username"],config["password"], config["server"])
|
||||
client = pymongo.MongoClient(connector)
|
||||
db = client["groclist"]
|
||||
|
||||
@app.route("/")
|
||||
def main():
|
||||
return render_template("login.html")
|
||||
return render_template("index.html")
|
||||
|
||||
@app.route("/login", methods=["POST"])
|
||||
def login()
|
||||
@app.route("/login", methods=["GET","POST"])
|
||||
def login():
|
||||
error = None
|
||||
username = request.form["username"]
|
||||
password = request.form["password"]
|
||||
if db.cred.find_one({"username": username, "password": password})
|
||||
auth_user_id = db.cred.find_one({"username": username},{"_id", 1})
|
||||
return redirect(url_for("welcome", id=auth_user_id["_id"]))
|
||||
else:
|
||||
error = "Usernaam of wachtwoord onbekend, probeer opnieuw"
|
||||
return render_template("login.html", error=error)
|
||||
if request.method == "POST":
|
||||
username = request.form["username"]
|
||||
password = request.form["password"]
|
||||
if db.cred.find_one({"username": username, "password": password}):
|
||||
auth_user_id = db.cred.find_one({"username": username},{"uuid", 1})
|
||||
if auth_user_id:
|
||||
app.logger.info(auth_user_id)
|
||||
return render_template("welcome.html", id=auth_user_id["uuid"])
|
||||
else:
|
||||
return render_template("404.html")
|
||||
else:
|
||||
error = "Usernaam of wachtwoord onbekend, probeer opnieuw"
|
||||
return render_template("login.html", error=error)
|
||||
|
||||
@app.route("/welcome")
|
||||
def welcome(id)
|
||||
@app.route("/welcome/<id>", methods=['GET'])
|
||||
def welcome(id):
|
||||
print("Hello: ", id)
|
||||
|
||||
# start server with run method
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
Reference in New Issue
Block a user