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(userRoutes, url_prefix='/user')
|
||||||
self.app.register_blueprint(eventRoutes, url_prefix='/event')
|
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):
|
def print_endpoints(self):
|
||||||
print("Endpoints and their functions:")
|
print("Endpoints and their functions:")
|
||||||
for rule in self.app.url_map.iter_rules():
|
for rule in self.app.url_map.iter_rules():
|
||||||
|
@ -72,6 +66,12 @@ class App:
|
||||||
def locate_upcoming_events(self):
|
def locate_upcoming_events(self):
|
||||||
with self.app.app_context():
|
with self.app.app_context():
|
||||||
print(EventNotifyerServer.locate_upcoming_events())
|
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_class_instance = App()
|
||||||
app_instance = app_class_instance.app
|
app_instance = app_class_instance.app
|
||||||
|
|
|
@ -34,15 +34,13 @@ def loginUser():
|
||||||
data = request.json
|
data = request.json
|
||||||
user = UserService.verify_user(data)
|
user = UserService.verify_user(data)
|
||||||
if user:
|
if user:
|
||||||
token = login(user)
|
response = login(user) # Get the response from the login function
|
||||||
response = user.to_dict()
|
|
||||||
response['token'] = token
|
|
||||||
response = jsonify(response)
|
|
||||||
return response, 200
|
return response, 200
|
||||||
else:
|
else:
|
||||||
return jsonify({'error': 'Invalid credentials'}), 400
|
return jsonify({'error': 'Invalid credentials'}), 400
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({'error': str(e)}), 500
|
return jsonify({'error': str(e)}), 500
|
||||||
|
|
||||||
|
|
||||||
@userRoutes.route('/logout', methods=['POST'])
|
@userRoutes.route('/logout', methods=['POST'])
|
||||||
@jwt_required(optional=True)
|
@jwt_required(optional=True)
|
||||||
|
@ -58,4 +56,4 @@ def login(user):
|
||||||
sessionToken = create_access_token(identity=user.id)
|
sessionToken = create_access_token(identity=user.id)
|
||||||
response = jsonify(user.to_dict())
|
response = jsonify(user.to_dict())
|
||||||
response.set_cookie('access_token_cookie', sessionToken, httponly=True, path='/')
|
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)
|
upcoming_deadline = now + timedelta(minutes=30)
|
||||||
events = Event.query.filter(
|
events = Event.query.filter(
|
||||||
|
|
||||||
Event.duedate <= upcoming_deadline,
|
# Event.duedate <= upcoming_deadline,
|
||||||
Event.deleted == False
|
Event.deleted == False
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue