# Condition Help or Best Practice

**URL:** <https://community.auth0.com/t/condition-help-or-best-practice/174831>\
**Category:** Auth0 Fine-Grained Authorization\
**Created:** [January 27, 2025, 7:15pm UTC](https://community.auth0.com/t/condition-help-or-best-practice/174831 "2025-01-27T19:15:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephenbawks1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephenbawks1/32/71238_2.png) [@stephenbawks1](https://community.auth0.com/u/stephenbawks1)\
**Post date:** [January 27, 2025, 7:15pm UTC](https://community.auth0.com/t/condition-help-or-best-practice/174831/1 "2025-01-27T19:15:24Z")

</div>

I am looking for some help on what’s the best way to do this. I think I know but I am curious if I am way off base here or not. I want to have a condition that will check to make sure a team member is part of a certain company or set of possible companies when trying to do something against a client.

I added a condition down below and I am curious if this would be the best way to achieve this or not?

```auto
model
  schema 1.1

type team_member

type company
  relations
    define member: [team_member]

type group
  relations
    define member: [team_member, group#member]

type clients
  relations
    define can_modify: owner
    define can_view: viewer
    define owner: [team_member with check_allowed_companies, group#member with check_allowed_companies]
    define viewer: [team_member with check_allowed_companies, group#member with check_allowed_companies] or owner

condition check_allowed_companies(team_member_company: map<string>, allowed_companies: list<string>) {
  team_member_company["company"] in allowed_companies 
}

```

---

<div class="post-metadata">

**Author:** ![andres.aguiar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andres.aguiar/32/7718_2.png) [@andres.aguiar](https://community.auth0.com/u/andres.aguiar)\
**Post date:** [January 27, 2025, 7:28pm UTC](https://community.auth0.com/t/condition-help-or-best-practice/174831/2 "2025-01-27T19:28:04Z")

</div>

Hi @stephenbawks1 !

Can you expand on what you want to accomplish? Why do you want to filter by company?

There might be a way to do something similar with contextual tuples, using this approach [Auth0 Fine-Grained Authorization (FGA) Docs | Auth0 Fine-Grained Authorization (FGA) Docs](https://docs.fga.dev/modeling/basics/organization-context-authorization), e.g you send a list of allowed companies as a contextual tuple.

---

<div class="post-metadata">

**Author:** ![stephenbawks1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephenbawks1/32/71238_2.png) [@stephenbawks1](https://community.auth0.com/u/stephenbawks1)\
**Post date:** [January 27, 2025, 7:30pm UTC](https://community.auth0.com/t/condition-help-or-best-practice/174831/3 "2025-01-27T19:30:34Z")

</div>

I think I would like to be able to define the client with a list of allowed companies and when the check is done against a team\_member or group, they would need to specify the company that team\_member or group is a part of and it would check that against the list of companies or company allowed for that client.

---

<div class="post-metadata">

**Author:** ![andres.aguiar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andres.aguiar/32/7718_2.png) [@andres.aguiar](https://community.auth0.com/u/andres.aguiar)\
**Post date:** [January 27, 2025, 7:57pm UTC](https://community.auth0.com/t/condition-help-or-best-practice/174831/4 "2025-01-27T19:57:45Z")

</div>

Yes, you can create a client\<-\>company relation

```auto
type clients
  relations
     define company : [company]
     define viewer: team_member from company 

```

would that work?

---

<div class="post-metadata">

**Author:** ![stephenbawks1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephenbawks1/32/71238_2.png) [@stephenbawks1](https://community.auth0.com/u/stephenbawks1)\
**Post date:** [January 27, 2025, 8:02pm UTC](https://community.auth0.com/t/condition-help-or-best-practice/174831/5 "2025-01-27T20:02:33Z")

</div>

Yes that would work. I think in that scenario I would need to define a client/company for each company then if there are multiple companies that may need access to the client.

Was wondering if that would be the best way to do that or define a condition.
