refactor: use SESSION_COOKIE_NAME instead of hardcoding "slapp"

This commit is contained in:
Son NK 2020-06-28 21:17:18 +02:00
parent 8e068eea30
commit c41bffbbae
3 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,7 @@ from flask import redirect, url_for, flash, make_response
from flask_login import logout_user
from app.auth.base import auth_bp
from app.config import SESSION_COOKIE_NAME
@auth_bp.route("/logout")
@ -9,7 +10,7 @@ def logout():
logout_user()
flash("You are logged out", "success")
response = make_response(redirect(url_for("auth.login")))
response.delete_cookie("slapp")
response.delete_cookie(SESSION_COOKIE_NAME)
response.delete_cookie("mfa")
response.delete_cookie("dark-mode")

View File

@ -144,6 +144,7 @@ DB_URI = os.environ["DB_URI"]
# Flask secret
FLASK_SECRET = os.environ["FLASK_SECRET"]
SESSION_COOKIE_NAME = "slapp"
MAILBOX_SECRET = FLASK_SECRET + "mailbox"
CUSTOM_ALIAS_SECRET = FLASK_SECRET + "custom_alias"

View File

@ -39,6 +39,7 @@ from app.config import (
FLASK_PROFILER_PASSWORD,
SENTRY_FRONT_END_DSN,
FIRST_ALIAS_DOMAIN,
SESSION_COOKIE_NAME,
)
from app.dashboard.base import dashboard_bp
from app.developer.base import developer_bp
@ -100,7 +101,7 @@ def create_app() -> Flask:
app.config["TEMPLATES_AUTO_RELOAD"] = True
# to avoid conflict with other cookie
app.config["SESSION_COOKIE_NAME"] = "slapp"
app.config["SESSION_COOKIE_NAME"] = SESSION_COOKIE_NAME
if URL.startswith("https"):
app.config["SESSION_COOKIE_SECURE"] = True
app.config["SESSION_COOKIE_SAMESITE"] = "Lax"