I am using permanent_session_lifetime to expire the session of the user after some period of inactivity. The problem is that, this request is made through ajax, so i can't redirect in ajax context with the normal behavior of the flask.
http://xxxx/login?next=%2Fusers%2Fajax_step1
Instead of this, I want to redirect to my logout route in the before_request, if the flask session expire. How can i do that?
@mod.before_request
def make_session_permanent():
session.modified = True
session.permanent = True
app.permanent_session_lifetime = timedelta(minutes=10)
@mod.route('/logout')
@login_required
def logout():
logout_user()
session.clear()
flash(gettext(u'You have been logged out.'))
return redirect(url_for('auth.login'))