diff --git a/Pipfile b/Pipfile index 03c6b68..cf4e90c 100644 --- a/Pipfile +++ b/Pipfile @@ -7,6 +7,7 @@ name = "pypi" pymongo = "*" flask = "*" python-dotenv = "*" +flask-login = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 616cf0f..e567b24 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "2845750caf44933171e5c0fa0a3d3693e3cbe3cb10b25811beee31ba0c5373a8" + "sha256": "83152be2bb3e3a9a067703edfbd891d9ffae91e077309104fdecae73bc5d967f" }, "pipfile-spec": 6, "requires": { @@ -32,14 +32,6 @@ "markers": "python_version >= '3.7'", "version": "==8.1.7" }, - "colorama": { - "hashes": [ - "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", - "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6" - ], - "markers": "platform_system == 'Windows'", - "version": "==0.4.6" - }, "dnspython": { "hashes": [ "sha256:5ef3b9680161f6fa89daf8ad451b5f1a33b18ae8a1c6778cdf4b43f08c0a6e50", @@ -57,6 +49,15 @@ "markers": "python_version >= '3.8'", "version": "==3.0.2" }, + "flask-login": { + "hashes": [ + "sha256:5e23d14a607ef12806c699590b89d0f0e0d67baeec599d75947bf9c147330333", + "sha256:849b25b82a436bf830a054e74214074af59097171562ab10bfa999e6b78aae5d" + ], + "index": "pypi", + "markers": "python_version >= '3.7'", + "version": "==0.6.3" + }, "itsdangerous": { "hashes": [ "sha256:2c2349112351b88699d8d4b6b075022c0808887cb7ad10069318a8b0bc88db44", diff --git a/app.py b/app.py index 4e243dc..c5bd29e 100644 --- a/app.py +++ b/app.py @@ -42,8 +42,13 @@ def home(): return render_template('start.html') # Handle authentication related stuff in authentication.py file -app.add_url_rule('/login', methods=["GET", "POST"], view_func=authentication.login) -app.add_url_rule('/signup', methods=["GET", "POST"], view_func=authentication.signup) +@app.route('/login', methods=["GET", "POST"]) +def login(): + return authentication.login(db) + +@app.route('/signup', methods=["GET", "POST"]) +def signup(): + return authentication.signup(db) @app.route("//decks") def allDecks(username): diff --git a/authentication.py b/authentication.py index 52297d7..1922bbf 100644 --- a/authentication.py +++ b/authentication.py @@ -1,15 +1,29 @@ -from flask import render_template, request, redirect, url_for -# from flask_login import LoginManager +from flask import render_template, request, redirect, url_for, session +from flask_login import LoginManager +import app -# login_manager = LoginManager() -def login(): +login_manager = LoginManager() + +class User(): + def __init__(self, is_authenticated, is_active, is_anonymous): + self.is_authenticated = is_authenticated + self.is_active = is_active + self.is_anonymous = is_anonymous + + +def login(db): + print(db) if request.method == 'POST': ## TODO: Login return "Someone pressed the login button huh, I better log you in." else: return render_template('login.html') -def signup(): - return render_template('signup.html') +def signup(db): + if request.method == 'POST': + username = request.form["username"] + password = request.form["password"] + else: + return render_template('signup.html')