Hello, I have a flow where users can create test a...
# ask-a-descoper
a
Hello, I have a flow where users can create test accounts for a product and I have some strange behaviour there. Path 1: • A new user registers • A new descope tenant is created • Http Connector gets called successfully (using correct {{tenant.id}} and {{tenant.name} in the post body) • But then I get the error message: "Illegal tenant requested" Path 2: • User already exists and is assigned to a tenant • User decides to create a new tenant for the product instead • Descope tenant is created • Http Connector gets called, BUT {{tenant.id}} and {{tenant.name}} are not set to the newly created one, but instead to the previously selected one Thanks in advance for any input
p
@Akash Jivane Can you take a look?
a
@Prashasth Baliga Yes!
@Andi Can you please share the flow JSON ?
a
a
Thanks for sharing the flow JSON I can see the issue. In your *"*Create Account in Subscription*"* step you’re using: `{{tenant.id}}`and
{{tenant.name}}
But since the tenant is created earlier in the flow, the
tenant
context is not automatically updated. So your connector is getting the wrong tenant (previous session / empty), which causes the
Illegal tenant requested
error. Can you please confirm this is how your current setup is ?
a
yes. the idea is the user shoudl be able to use an existing tenant or create a new one
d
Hi @Andi, do you have this set in your JWT template? (see below screenshot). It will auto select the created tenant in case the user has a single tenant assigned. If the user belongs to multiple tenants there is no way to know what is the required selected tenant, so after the “Create Tenant” action you can add a tenant switcher for the user to select the relevant tenant, or, use a Scriptlet action to set the relevant tenant.
a
if the user has more tenants, is there a way to find out which of the tenants is the one that just got created in the scriptlet?
d
I don’t think so, but let me check.
We will add an option to the “Create Tenant” action, to select the created one.
a
Awesome! Thank you
d
Hi @Andi Implemented, you now have the ability to select if you want to set the created tenant as the current selected tenant:
a
Works like a charm. Thank you very much!
d
Sure 👍