fix user has to login again after quitting the browser
This commit is contained in:
parent
59764f8e84
commit
8e068eea30
20
server.py
20
server.py
|
@ -1,9 +1,20 @@
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
import flask_profiler
|
import flask_profiler
|
||||||
import os
|
import os
|
||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
import ssl
|
import ssl
|
||||||
from flask import Flask, redirect, url_for, render_template, request, jsonify, flash
|
from flask import (
|
||||||
|
Flask,
|
||||||
|
redirect,
|
||||||
|
url_for,
|
||||||
|
render_template,
|
||||||
|
request,
|
||||||
|
jsonify,
|
||||||
|
flash,
|
||||||
|
session,
|
||||||
|
)
|
||||||
from flask_admin import Admin
|
from flask_admin import Admin
|
||||||
from flask_cors import cross_origin, CORS
|
from flask_cors import cross_origin, CORS
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
@ -125,6 +136,13 @@ def create_app() -> Flask:
|
||||||
# enable CORS on /api endpoints
|
# enable CORS on /api endpoints
|
||||||
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
|
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
|
||||||
|
|
||||||
|
# set session to permanent so user stays signed in after quitting the browser
|
||||||
|
# the cookie is valid for 7 days
|
||||||
|
@app.before_request
|
||||||
|
def make_session_permanent():
|
||||||
|
session.permanent = True
|
||||||
|
app.permanent_session_lifetime = timedelta(days=7)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue