remove envs used for proton beta link (#1189)
* remove envs used for proton beta link * remove is_connect_with_proton_enabled()
This commit is contained in:
parent
c3c0b045db
commit
97805173cb
|
@ -5,11 +5,11 @@ from wtforms import StringField, validators
|
||||||
|
|
||||||
from app.auth.base import auth_bp
|
from app.auth.base import auth_bp
|
||||||
from app.auth.views.login_utils import after_login
|
from app.auth.views.login_utils import after_login
|
||||||
|
from app.config import CONNECT_WITH_PROTON
|
||||||
from app.events.auth_event import LoginEvent
|
from app.events.auth_event import LoginEvent
|
||||||
from app.extensions import limiter
|
from app.extensions import limiter
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import User
|
from app.models import User
|
||||||
from app.proton.utils import is_connect_with_proton_enabled
|
|
||||||
from app.utils import sanitize_email, sanitize_next_url
|
from app.utils import sanitize_email, sanitize_next_url
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,5 +68,5 @@ def login():
|
||||||
form=form,
|
form=form,
|
||||||
next_url=next_url,
|
next_url=next_url,
|
||||||
show_resend_activation=show_resend_activation,
|
show_resend_activation=show_resend_activation,
|
||||||
connect_with_proton=is_connect_with_proton_enabled(),
|
connect_with_proton=CONNECT_WITH_PROTON,
|
||||||
)
|
)
|
||||||
|
|
|
@ -249,10 +249,6 @@ PROTON_VALIDATE_CERTS = "PROTON_VALIDATE_CERTS" in os.environ
|
||||||
CONNECT_WITH_PROTON = "CONNECT_WITH_PROTON" in os.environ
|
CONNECT_WITH_PROTON = "CONNECT_WITH_PROTON" in os.environ
|
||||||
PROTON_EXTRA_HEADER_NAME = os.environ.get("PROTON_EXTRA_HEADER_NAME")
|
PROTON_EXTRA_HEADER_NAME = os.environ.get("PROTON_EXTRA_HEADER_NAME")
|
||||||
PROTON_EXTRA_HEADER_VALUE = os.environ.get("PROTON_EXTRA_HEADER_VALUE")
|
PROTON_EXTRA_HEADER_VALUE = os.environ.get("PROTON_EXTRA_HEADER_VALUE")
|
||||||
CONNECT_WITH_PROTON_COOKIE_NAME = os.environ.get(
|
|
||||||
"CONNECT_WITH_PROTON_COOKIE_NAME", "enable-proton"
|
|
||||||
)
|
|
||||||
PROTON_ALLOW_INTERNAL_LINK = "PROTON_ALLOW_INTERNAL_LINK" in os.environ
|
|
||||||
|
|
||||||
# in seconds
|
# in seconds
|
||||||
AVATAR_URL_EXPIRATION = 3600 * 24 * 7 # 1h*24h/d*7d=1week
|
AVATAR_URL_EXPIRATION = 3600 * 24 * 7 # 1h*24h/d*7d=1week
|
||||||
|
|
|
@ -6,10 +6,11 @@ from flask_login import login_required, current_user
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms import PasswordField, validators
|
from wtforms import PasswordField, validators
|
||||||
|
|
||||||
|
from app.config import CONNECT_WITH_PROTON
|
||||||
from app.dashboard.base import dashboard_bp
|
from app.dashboard.base import dashboard_bp
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import PartnerUser
|
from app.models import PartnerUser
|
||||||
from app.proton.utils import is_connect_with_proton_enabled, get_proton_partner
|
from app.proton.utils import get_proton_partner
|
||||||
from app.utils import sanitize_next_url
|
from app.utils import sanitize_next_url
|
||||||
|
|
||||||
_SUDO_GAP = 900
|
_SUDO_GAP = 900
|
||||||
|
@ -41,7 +42,7 @@ def enter_sudo():
|
||||||
else:
|
else:
|
||||||
flash("Incorrect password", "warning")
|
flash("Incorrect password", "warning")
|
||||||
|
|
||||||
proton_enabled = is_connect_with_proton_enabled()
|
proton_enabled = CONNECT_WITH_PROTON
|
||||||
if proton_enabled:
|
if proton_enabled:
|
||||||
# Only for users that have the account linked
|
# Only for users that have the account linked
|
||||||
partner_user = PartnerUser.get_by(user_id=current_user.id)
|
partner_user = PartnerUser.get_by(user_id=current_user.id)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
from flask import (
|
from flask import (
|
||||||
|
@ -12,7 +13,6 @@ from flask_login import login_required, current_user
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from flask_wtf.file import FileField
|
from flask_wtf.file import FileField
|
||||||
from newrelic import agent
|
from newrelic import agent
|
||||||
from typing import Optional, Tuple
|
|
||||||
from wtforms import StringField, validators
|
from wtforms import StringField, validators
|
||||||
from wtforms.fields.html5 import EmailField
|
from wtforms.fields.html5 import EmailField
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ from app.config import (
|
||||||
URL,
|
URL,
|
||||||
FIRST_ALIAS_DOMAIN,
|
FIRST_ALIAS_DOMAIN,
|
||||||
ALIAS_RANDOM_SUFFIX_LENGTH,
|
ALIAS_RANDOM_SUFFIX_LENGTH,
|
||||||
|
CONNECT_WITH_PROTON,
|
||||||
)
|
)
|
||||||
from app.dashboard.base import dashboard_bp
|
from app.dashboard.base import dashboard_bp
|
||||||
from app.db import Session
|
from app.db import Session
|
||||||
|
@ -52,7 +53,7 @@ from app.models import (
|
||||||
PartnerSubscription,
|
PartnerSubscription,
|
||||||
UnsubscribeBehaviourEnum,
|
UnsubscribeBehaviourEnum,
|
||||||
)
|
)
|
||||||
from app.proton.utils import is_connect_with_proton_enabled, get_proton_partner
|
from app.proton.utils import get_proton_partner
|
||||||
from app.utils import random_string, sanitize_email
|
from app.utils import random_string, sanitize_email
|
||||||
|
|
||||||
|
|
||||||
|
@ -412,7 +413,7 @@ def setting():
|
||||||
coinbase_sub=coinbase_sub,
|
coinbase_sub=coinbase_sub,
|
||||||
FIRST_ALIAS_DOMAIN=FIRST_ALIAS_DOMAIN,
|
FIRST_ALIAS_DOMAIN=FIRST_ALIAS_DOMAIN,
|
||||||
ALIAS_RAND_SUFFIX_LENGTH=ALIAS_RANDOM_SUFFIX_LENGTH,
|
ALIAS_RAND_SUFFIX_LENGTH=ALIAS_RANDOM_SUFFIX_LENGTH,
|
||||||
connect_with_proton=is_connect_with_proton_enabled(),
|
connect_with_proton=CONNECT_WITH_PROTON,
|
||||||
proton_linked_account=proton_linked_account,
|
proton_linked_account=proton_linked_account,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import arrow
|
|
||||||
from flask import make_response, redirect, url_for, flash
|
from flask import make_response, redirect, url_for, flash
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
|
||||||
from .base import internal_bp
|
from .base import internal_bp
|
||||||
from app import config
|
|
||||||
|
|
||||||
|
|
||||||
@internal_bp.route("/integrations/proton")
|
@internal_bp.route("/integrations/proton")
|
||||||
|
@ -13,14 +12,6 @@ def set_enable_proton_cookie():
|
||||||
redirect_url = url_for("auth.login")
|
redirect_url = url_for("auth.login")
|
||||||
|
|
||||||
response = make_response(redirect(redirect_url))
|
response = make_response(redirect(redirect_url))
|
||||||
if config.PROTON_ALLOW_INTERNAL_LINK:
|
|
||||||
flash("You can now connect your Proton and your SimpleLogin account", "success")
|
flash("You can now connect your Proton and your SimpleLogin account", "success")
|
||||||
response.set_cookie(
|
|
||||||
config.CONNECT_WITH_PROTON_COOKIE_NAME,
|
|
||||||
value="true",
|
|
||||||
expires=arrow.now().shift(days=30).datetime,
|
|
||||||
secure=True if config.URL.startswith("https") else False,
|
|
||||||
httponly=True,
|
|
||||||
samesite="Lax",
|
|
||||||
)
|
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
from typing import Optional
|
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.db import Session
|
||||||
from app.errors import ProtonPartnerNotSetUp
|
from app.errors import ProtonPartnerNotSetUp
|
||||||
from app.models import Partner
|
from app.models import Partner
|
||||||
|
@ -22,15 +19,5 @@ def get_proton_partner() -> Partner:
|
||||||
return _PROTON_PARTNER
|
return _PROTON_PARTNER
|
||||||
|
|
||||||
|
|
||||||
def is_proton_partner(partner: Partner) -> str:
|
def is_proton_partner(partner: Partner) -> bool:
|
||||||
return partner.name == PROTON_PARTNER_NAME
|
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
|
|
||||||
|
|
Loading…
Reference in New Issue