Change g.user to user in routes.py