-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support globs for org approvals (#9367)
* feat: refactor 4 sql queries to kysely Signed-off-by: Matt Krick <matt.krick@gmail.com> * feat: refactor removeApprovalOD to kysely Signed-off-by: Matt Krick <matt.krick@gmail.com> * feat: support wildcards in OrgApprovalDomains rules Signed-off-by: Matt Krick <matt.krick@gmail.com> * support org approval for invites Signed-off-by: Matt Krick <matt.krick@gmail.com> --------- Signed-off-by: Matt Krick <matt.krick@gmail.com>
- Loading branch information
Showing
18 changed files
with
81 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
packages/server/graphql/public/mutations/helpers/getIsUserIdApprovedByOrg.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
packages/server/postgres/queries/getApprovedOrganizationDomainsByDomainFromPG.ts
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
packages/server/postgres/queries/getApprovedOrganizationDomainsFromPG.ts
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/server/postgres/queries/insertApprovedOrganizationDomains.ts
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
packages/server/postgres/queries/removeApprovedOrganizationDomainsToPG.ts
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
packages/server/postgres/queries/src/getApprovedOrganizationDomainsByDomainsQuery.sql
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
packages/server/postgres/queries/src/getApprovedOrganizationDomainsQuery.sql
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
packages/server/postgres/queries/src/insertApprovedOrganizationDomainsQuery.sql
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
packages/server/postgres/queries/src/removeApprovedOrganizationDomainsQuery.sql
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
packages/server/postgres/queries/src/updateDomainsInOrganizationApprovedDomainQuery.sql
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
packages/server/postgres/queries/updateDomainsInOrganizationApprovedDomainToPG.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import {DataLoaderWorker} from '../graphql/graphql' | ||
|
||
const isEmailVerificationRequired = async (email: string, dataLoader: DataLoaderWorker) => { | ||
const domain = email.split('@')[1]! | ||
const [approvedEmail, approvedDomain] = await Promise.all([ | ||
const exactDomain = email.split('@')[1]! | ||
|
||
// search for wildcards, too | ||
const [tld, domain] = exactDomain.split('.').reverse() | ||
const wildcardDomain = `*.${domain}.${tld}` | ||
|
||
const [approvedEmail, approvedDomain, approvedWildcardDomain] = await Promise.all([ | ||
dataLoader.get('organizationApprovedDomains').load(email), | ||
dataLoader.get('organizationApprovedDomains').load(domain) | ||
dataLoader.get('organizationApprovedDomains').load(exactDomain), | ||
dataLoader.get('organizationApprovedDomains').load(wildcardDomain) | ||
]) | ||
return approvedEmail || approvedDomain | ||
return approvedEmail || approvedDomain || approvedWildcardDomain | ||
} | ||
|
||
export default isEmailVerificationRequired |