commit 62e042567223a468424a2689b71da6a6ec400c6b
parent c3fb5d49ebac0b044fab99f16e0683ac09c2cd28
Author: Brennen T. Mazur <brennen@madis.cool>
Date: Thu, 5 Jan 2023 08:51:07 -0700
gave login its own page
Diffstat:
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/app.py b/app.py
@@ -9,7 +9,13 @@ OrganizationName = "Youth Employment Program"
app = Flask(__name__)
-# Mongo setup
+# Mongo setup ##Do we need a ConnectionFailure check? pymongo.errors import ConnectionFailure
+## client = MongoClient()
+## try:
+## client.admin.command('ping')
+## except ConnectionFailure:
+## print("Server not available")
+## Then bcrypt, create db and create collections
client = MongoClient()
client = MongoClient('localhost', 27017)
bcrypt = Bcrypt(app)
@@ -18,9 +24,9 @@ app.config['SECRET_KEY'] = 'secretkey'
# Mongo setup
# Login manager
-login_manager = LoginManager()
-login_manager.init_app(app)
-login_manager.login_view = 'login'
+#login_manager = LoginManager()
+#login_manager.init_app(app)
+#login_manager.login_view = 'login'
# @login_manager.user_loader
# def load_user(user_id):
@@ -33,10 +39,14 @@ collection = db['users-collection'] # Make aditional user info single document/a
# Database collections/documents
# Routes
-@app.route('/')
+@app.route('/') #main route should check if user is logged in, then redirect to /dashboard else redirect to /login
def hello():
return render_template('index.html',ORGNAME = OrganizationName) #This implimentation is messy, maybe abstract to a defPage()?
+@app.route("/login")
+def login():
+ return render_template('login.html',ORGNAME = OrganizationName)
+
@app.route("/dashboard")
def dashboard():
return render_template('dashboard/layout.html',currenttime=datetime.datetime.utcnow(),ORGNAME=OrganizationName)
diff --git a/templates/index.html b/templates/index.html
@@ -2,12 +2,6 @@
{% block content %}
<section class="login-grid">
- <form class="login">
- <label for="username">Login: </label>
- <input type="text" id="username" name="username"><br>
- <label for="password">Password: </label>
- <input type="password" id="password" name="password"><br>
- <input type="submit" value="Login">
- </form>
+ <h2>Page calls getUser()</h2><h6>Returns object of user data for redirection to dashboard, else directs to /login</h6>
</section>
{% endblock %}
diff --git a/templates/index.html b/templates/login.html