Skip to content

Commit

Permalink
Add flask-login, create User class
Browse files Browse the repository at this point in the history
  • Loading branch information
iltenahmet committed Feb 26, 2024
1 parent ca6fd11 commit 006da2c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name = "pypi"
pymongo = "*"
flask = "*"
python-dotenv = "*"
flask-login = "*"

[dev-packages]

Expand Down
19 changes: 10 additions & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("/<username>/decks")
def allDecks(username):
Expand Down
26 changes: 20 additions & 6 deletions authentication.py
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 006da2c

Please sign in to comment.