Skip to content

Commit 25f6754

Browse files
committed
Simplify type validation
1 parent 6b32200 commit 25f6754

File tree

1 file changed

+3
-8
lines changed
  • python-flask-admin-portal-example

1 file changed

+3
-8
lines changed

python-flask-admin-portal-example/app.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from typing import TypeGuard, get_args
2+
from typing import TypeGuard, cast, get_args
33
from flask import Flask, redirect, render_template, request, url_for
44
import workos
55
from workos import client as workos_client
@@ -23,12 +23,6 @@
2323
workos.base_api_url = "http://localhost:7000/" if DEBUG else workos.base_api_url
2424

2525

26-
def is_portal_link_intent(
27-
value: str,
28-
) -> TypeGuard[workos.portal.PortalLinkIntent]:
29-
return value in get_args(workos.portal.PortalLinkIntent)
30-
31-
3226
@app.route("/")
3327
def index():
3428
return render_template("index.html")
@@ -69,10 +63,11 @@ def provision_enterprise():
6963
@app.route("/launch_admin_portal", methods=["GET", "POST"])
7064
def launch_admin_portal():
7165
intent = request.args.get("intent")
66+
7267
if intent is None:
7368
return "Missing intent parameter", 400
7469

75-
if not is_portal_link_intent(intent):
70+
if not intent in tuple(("audit_logs", "dsync", "log_streams", "sso")):
7671
return "Invalid intent parameter", 400
7772

7873
portal_link = workos_client.portal.generate_link(

0 commit comments

Comments
 (0)