mirror of
https://github.com/simple-login/app.git
synced 2025-02-25 08:13:16 +08:00
Merge pull request #954 from simple-login/fix-proton-login
allow the code to run without proton partner
This commit is contained in:
commit
7e00dfddc3
3 changed files with 12 additions and 2 deletions
|
@ -28,6 +28,7 @@ from app.email_utils import (
|
|||
email_can_be_used_as_mailbox,
|
||||
personal_email_already_used,
|
||||
)
|
||||
from app.errors import ProtonPartnerNotSetUp
|
||||
from app.log import LOG
|
||||
from app.models import (
|
||||
BlockBehaviourEnum,
|
||||
|
@ -68,7 +69,11 @@ class PromoCodeForm(FlaskForm):
|
|||
|
||||
def get_proton_linked_account() -> Optional[str]:
|
||||
# Check if the current user has a partner_id
|
||||
proton_partner_id = get_proton_partner_id()
|
||||
try:
|
||||
proton_partner_id = get_proton_partner_id()
|
||||
except ProtonPartnerNotSetUp:
|
||||
return None
|
||||
|
||||
if current_user.partner_id != proton_partner_id:
|
||||
return None
|
||||
|
||||
|
|
|
@ -56,3 +56,7 @@ class MailSentFromReverseAlias(SLException):
|
|||
"""raised when receiving an email sent from a reverse alias"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class ProtonPartnerNotSetUp(SLException):
|
||||
pass
|
||||
|
|
|
@ -5,6 +5,7 @@ from flask import url_for
|
|||
from typing import Optional
|
||||
|
||||
from app.db import Session
|
||||
from app.errors import ProtonPartnerNotSetUp
|
||||
from app.models import User, PartnerUser, Partner
|
||||
from app.proton.proton_client import ProtonClient, ProtonUser
|
||||
from app.utils import random_string
|
||||
|
@ -18,7 +19,7 @@ def get_proton_partner_id() -> int:
|
|||
if _PROTON_PARTNER_ID is None:
|
||||
partner = Partner.get_by(name=PROTON_PARTNER_NAME)
|
||||
if partner is None:
|
||||
raise Exception("Could not find Proton Partner instance")
|
||||
raise ProtonPartnerNotSetUp
|
||||
_PROTON_PARTNER_ID = partner.id
|
||||
|
||||
return _PROTON_PARTNER_ID
|
||||
|
|
Loading…
Reference in a new issue