refactor(sso): update trusted origins handling and introduce license validation

- Replaced user data fetching with a dedicated query for trusted origins in SSO settings.
- Updated mutation functions to utilize the new trusted origins query.
- Introduced a new service function to validate enterprise licenses based on organization ownership.
- Enhanced SSO router to ensure trusted origins are managed by the organization owner.
- Added callback URL for email sign-in in the home page.
This commit is contained in:
Mauricio Siu
2026-02-18 01:34:07 -06:00
parent 756d276f47
commit 6c3230648a
9 changed files with 132 additions and 43 deletions
@@ -0,0 +1,29 @@
import { db } from "@dokploy/server/db";
import { organization, user } from "@dokploy/server/db/schema";
import { eq } from "drizzle-orm";
export const hasValidLicense = async (organizationId: string) => {
// we need to find the owner of the organization
const organizationResult = await db.query.organization.findFirst({
where: eq(organization.id, organizationId),
columns: { ownerId: true },
});
if (!organizationResult) {
return false;
}
const ownerId = organizationResult?.ownerId;
const currentUser = await db.query.user.findFirst({
where: eq(user.id, ownerId),
columns: {
enableEnterpriseFeatures: true,
isValidEnterpriseLicense: true,
},
});
return !!(
currentUser?.enableEnterpriseFeatures &&
currentUser?.isValidEnterpriseLicense
);
};