mirror of
https://github.com/simple-login/app.git
synced 2024-11-02 20:01:01 +01:00
99ce10a1bc
* Send email to users with a subscription and a partner plan upgrade * Update double-subscription-partner.html * Update double-subscription-partner.txt.jinja2 Co-authored-by: Adrià Casajús <adria.casajus@proton.ch> Co-authored-by: Son Nguyen Kim <nguyenkims@users.noreply.github.com>
37 lines
969 B
Python
37 lines
969 B
Python
from typing import Optional
|
|
|
|
from app.config import CONNECT_WITH_PROTON, CONNECT_WITH_PROTON_COOKIE_NAME
|
|
from flask import request
|
|
|
|
from app.db import Session
|
|
from app.errors import ProtonPartnerNotSetUp
|
|
from app.models import Partner
|
|
|
|
PROTON_PARTNER_NAME = "Proton"
|
|
_PROTON_PARTNER: Optional[Partner] = None
|
|
|
|
|
|
def get_proton_partner() -> Partner:
|
|
global _PROTON_PARTNER
|
|
if _PROTON_PARTNER is None:
|
|
partner = Partner.get_by(name=PROTON_PARTNER_NAME)
|
|
if partner is None:
|
|
raise ProtonPartnerNotSetUp
|
|
Session.expunge(partner)
|
|
_PROTON_PARTNER = partner
|
|
return _PROTON_PARTNER
|
|
|
|
|
|
def is_proton_partner(partner: Partner) -> str:
|
|
return partner.name == PROTON_PARTNER_NAME
|
|
|
|
|
|
def is_connect_with_proton_enabled() -> bool:
|
|
if CONNECT_WITH_PROTON:
|
|
return True
|
|
if CONNECT_WITH_PROTON_COOKIE_NAME and request.cookies.get(
|
|
CONNECT_WITH_PROTON_COOKIE_NAME
|
|
):
|
|
return True
|
|
return False
|