mirror of
https://github.com/simple-login/app.git
synced 2024-10-02 14:41:29 +02:00
26 lines
810 B
Python
26 lines
810 B
Python
|
import arrow
|
||
|
from app.config import CONNECT_WITH_PROTON_COOKIE_NAME, URL
|
||
|
from flask import make_response, redirect, url_for
|
||
|
from flask_login import current_user
|
||
|
from .base import internal_bp
|
||
|
|
||
|
|
||
|
@internal_bp.route("/integrations/proton")
|
||
|
def set_enable_proton_cookie():
|
||
|
if current_user.is_authenticated:
|
||
|
redirect_url = url_for("dashboard.index")
|
||
|
else:
|
||
|
redirect_url = url_for("auth.login")
|
||
|
|
||
|
response = make_response(redirect(redirect_url))
|
||
|
if CONNECT_WITH_PROTON_COOKIE_NAME:
|
||
|
response.set_cookie(
|
||
|
CONNECT_WITH_PROTON_COOKIE_NAME,
|
||
|
value="true",
|
||
|
expires=arrow.now().shift(days=30).datetime,
|
||
|
secure=True if URL.startswith("https") else False,
|
||
|
httponly=True,
|
||
|
samesite="Lax",
|
||
|
)
|
||
|
return response
|