mirror of
https://github.com/hanzoai/sign.git
synced 2026-11-02 23:26:15 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { prisma } from '@hanzo/esign-prisma';
|
|
|
|
const LEGACY_SERVICE_ACCOUNT_EMAIL = '[email protected]';
|
|
|
|
export const legacyServiceAccountEmail = () => {
|
|
try {
|
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
if (process.env.NEXT_PRIVATE_LEGACY_SERVICE_ACCOUNT_EMAIL) {
|
|
// eslint-disable-next-line turbo/no-undeclared-env-vars
|
|
return process.env.NEXT_PRIVATE_LEGACY_SERVICE_ACCOUNT_EMAIL;
|
|
}
|
|
|
|
const { hostname } = new URL(process.env.NEXT_PUBLIC_WEBAPP_URL || 'http://localhost:3000');
|
|
|
|
return `serviceaccount@${hostname}`;
|
|
} catch (error) {
|
|
return LEGACY_SERVICE_ACCOUNT_EMAIL;
|
|
}
|
|
};
|
|
|
|
export const migrateLegacyServiceAccount = async () => {
|
|
if (legacyServiceAccountEmail() !== LEGACY_SERVICE_ACCOUNT_EMAIL) {
|
|
console.log(`Migrating legacy service account to new email: ${legacyServiceAccountEmail()}`);
|
|
|
|
await prisma.user.updateMany({
|
|
where: {
|
|
email: LEGACY_SERVICE_ACCOUNT_EMAIL,
|
|
},
|
|
data: {
|
|
email: legacyServiceAccountEmail(),
|
|
},
|
|
});
|
|
}
|
|
};
|