I have found a similar question here, but the answer does not seem to work for me.
I use Flask User (which extends Flask Login, I believe) and for the most part it works very well. I have built my own completely fresh templates for sign in and registration, rather than using their provided ones. Following the documentation, I have placed these templates at templates/flask_user/login.html, templates/flask_user/register.html and so on.
I have also set USER_UNAUTHENTICATED_ENDPOINT = "login" and USER_UNAUTHORIZED_ENDPOINT = "login" in my config file, where login is the name of my login route.
The problem is that if I'm signed out and I try to directly access a page that requires the user to be logged in, I will be sent to http://localhost:5000/user/sign-in and shown the Flask-Login sign in page. Two things wrong with this: 1) This is not the correct route for signing in, and 2) This is not the correct template for signing in.
I'd be grateful for any help anybody can suggest for this, please.
EDIT:
Code from __init__.py that initialises the app and the LoginManager:
app = Flask(__name__)
@app.context_processor
def inject_production_status():
return dict(production=True)
# Initialise flask_login
login = LoginManager(app)
login.login_view = 'login'
login.refresh_view = "login"
login.needs_refresh_message = "Please sign in again to access this page"
UserManager is defined at the bottom of models.py:
user_manager = UserManager(app, db, User)