dayday0calories / CITS5505-Group-Project

CITS5505 Group Project
MIT License
0 stars 0 forks source link

Bug: "User undefined" when previous user hasn't logged out #22

Open lingering126 opened 1 month ago

lingering126 commented 1 month ago

I found that if the previous user hasn't logged out, run the flask app again and there will be a "user undefined" bug. Screenshot 2024-05-16 220157

lingering126 commented 1 month ago

I added this routes, and the bug fixed:

@pr.before_request
def before_request():
    g.user = current_user if current_user.is_authenticated else None

this code sets g.user to the currently logged-in user (if there is one) before each request, making the current_user object available globally throughout the request.