mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-22 20:08:46 +00:00
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:
@@ -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
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user