From 868617195721488e9e9a06a5a95a0040f01ddff2 Mon Sep 17 00:00:00 2001 From: Kelly Diabagate Date: Sun, 28 Mar 2021 12:55:56 -0500 Subject: [PATCH] session --- app.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index b432171..faeade8 100644 --- a/app.py +++ b/app.py @@ -155,7 +155,9 @@ def generate_ayat(): @app.route("/api/auth", methods=["POST"]) def auth(): - print('firing auth') + print('firing auth', session) + print('session user', session.get('user')) + print('session user', session['user']) data = json.loads(request.data) userData = json.loads(data["data"]) @@ -190,8 +192,7 @@ def auth(): return (jsonify(response=isAuthenticated), 200 ) elif mode == 'register': - - + try: user = User.register( first_name = userData["first_name"], @@ -285,6 +286,7 @@ def auth(): elif mode == 'login': if 'user' in session and session['user']["first_name"] == userData["username"]: + session["isAuthenticated"] = user.username isAuthenticated = True return (jsonify(response=isAuthenticated, user=session['user'], tajweed=session['tajweed']), 200 ) else: @@ -406,7 +408,7 @@ def auth(): @app.route('/api/logout') def logout(): - print('in logout') + print('in logout', session) session.pop('isAuthenticated', None) session.pop('user', None) session.pop('tajweed', None) @@ -923,8 +925,10 @@ def remove_student(): @app.route('/api/fetch_rules') def fetch_rules(): - # print('in fetch_rules', session) - # print('session user', session.get('user')) + print('in fetch_rules', session) + print('session user', session.get('user')) + print('session user', session['user']) + # curr_user = session.get('user') # user = User.query.filter_by(username=curr_user['username']).first()