fixing login response
This commit is contained in:
parent
e718ae905d
commit
3c9e7bca64
3 changed files with 10 additions and 12 deletions
12
app.py
12
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
|
||||
|
|
|
@ -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
|
||||
return response # Return the response object with the cookie
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue