Simplify redirect condition on account_activated

This commit is contained in:
Carlos Quintana 2022-05-20 11:50:02 +02:00
parent 521f6b5822
commit afb7f5ef42
No known key found for this signature in database
GPG Key ID: 15E73DCC410679F8
1 changed files with 14 additions and 16 deletions

View File

@ -16,19 +16,6 @@ class Browser(Enum):
Other = 4
def get_browser() -> Browser:
user_agent = request.user_agent
if user_agent.platform in ["android", "iphone", "ipad']:
return Browser.Other
if user_agent.browser == "edge":
return Browser.Edge
elif user_agent.browser in ["chrome", "opera", "webkit"]:
return Browser.Chrome
elif user_agent.browser in ["mozilla", "firefox"]:
return Browser.Firefox
return Browser.Other
def is_mobile() -> bool:
return request.user_agent.platform in [
"android",
@ -39,12 +26,23 @@ def is_mobile() -> bool:
]
def get_browser() -> Browser:
if is_mobile():
return Browser.Other
user_agent = request.user_agent
if user_agent.browser == "edge":
return Browser.Edge
elif user_agent.browser in ["chrome", "opera", "webkit"]:
return Browser.Chrome
elif user_agent.browser in ["mozilla", "firefox"]:
return Browser.Firefox
return Browser.Other
@onboarding_bp.route("/account_activated", methods=["GET"])
@login_required
def account_activated():
if is_mobile():
return redirect(url_for("dashboard.index"))
browser = get_browser()
if browser == Browser.Chrome:
extension_link = CHROME_EXTENSION_LINK