Reputation: 1
I'm building a flask app that uses Google OAuth to login. I can log in no problem but when I change directories to work access different pages in the app the login resets. I'm wondering what I might need to add to keep the user logged in.
app
- core
- email
- error pages
- generator
- views.py
- static
- templates
- users
- views.py
- main.py
The user logs in from users/views.py but when accessing pages from generator/views.py they suddenly get logged out.
generator/views.py
from flask import render_template, url_for, flash, redirect, request, Blueprint, session, abort
from flask_login import login_required, current_user
from menutime import db
from menutime.generator.engine import meal_selector, populate_shopping_list
from menutime.models import Meal_Details, Selections
generator = Blueprint('generator',__name__)
@generator.route("/selections", methods=["GET", "POST"])
@login_required
def selections():
if request.method == "POST":
# global this_weeks_ids
global category_selected, desired_servings
category_selected = []
category_selected.append(int(request.form["fish_meals"]))
desired_servings = int(request.form["servings"])
return redirect(url_for('generator.menu'))
return render_template('selections.html')
Am I missing something besides @login_required that would indicate who the user is?
I tried adding without any success
@login_manager.user_loader def load_user(user_id): return User.get(user_id)
Upvotes: 0
Views: 39
Reputation: 1
I had app.config["Secret_Key"] set to random, this was causing my issue. Once I changed it to a static variable the site started working properly.
Upvotes: 0