From 3c9e7bca64191dbc93a29b9ecb0c404db428e208 Mon Sep 17 00:00:00 2001 From: Kfir Dayan Date: Tue, 9 Jan 2024 10:14:28 +0200 Subject: [PATCH] fixing login response --- app.py | 12 ++++++------ routes/userRoutes.py | 8 +++----- services/EventService.py | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app.py b/app.py index f9cd141..3a5cbc4 100644 --- a/app.py +++ b/app.py @@ -52,12 +52,6 @@ class App: self.app.register_blueprint(userRoutes, url_prefix='/user') self.app.register_blueprint(eventRoutes, url_prefix='/event') - def run(self): - with self.app.app_context(): - db.create_all() - self.setup_scheduler() # Setup scheduler - self.app.run(debug=True) - def print_endpoints(self): print("Endpoints and their functions:") for rule in self.app.url_map.iter_rules(): @@ -72,6 +66,12 @@ class App: def locate_upcoming_events(self): with self.app.app_context(): print(EventNotifyerServer.locate_upcoming_events()) + + def run(self): + with self.app.app_context(): + db.create_all() + self.setup_scheduler() # Setup scheduler + self.app.run(port=8000, debug=True) app_class_instance = App() app_instance = app_class_instance.app diff --git a/routes/userRoutes.py b/routes/userRoutes.py index 0f2b39c..f2674ce 100644 --- a/routes/userRoutes.py +++ b/routes/userRoutes.py @@ -34,15 +34,13 @@ def loginUser(): data = request.json user = UserService.verify_user(data) if user: - token = login(user) - response = user.to_dict() - response['token'] = token - response = jsonify(response) + response = login(user) # Get the response from the login function return response, 200 else: return jsonify({'error': 'Invalid credentials'}), 400 except Exception as e: return jsonify({'error': str(e)}), 500 + @userRoutes.route('/logout', methods=['POST']) @jwt_required(optional=True) @@ -58,4 +56,4 @@ def login(user): sessionToken = create_access_token(identity=user.id) response = jsonify(user.to_dict()) response.set_cookie('access_token_cookie', sessionToken, httponly=True, path='/') - return sessionToken \ No newline at end of file + return response # Return the response object with the cookie diff --git a/services/EventService.py b/services/EventService.py index cf5eb59..dfcb317 100644 --- a/services/EventService.py +++ b/services/EventService.py @@ -143,7 +143,7 @@ class EventService: upcoming_deadline = now + timedelta(minutes=30) events = Event.query.filter( - Event.duedate <= upcoming_deadline, + # Event.duedate <= upcoming_deadline, Event.deleted == False ).all()