Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+14
-25
@@ -6,7 +6,6 @@ import { getAllRoles } from "../db/permissions/roles.db.server";
|
||||
import { createTenant, createTenantUser, getTenantBySlug } from "../db/tenants.db.server";
|
||||
import { getUserByEmail, register } from "../db/users.db.server";
|
||||
import { queueTransactionalEmail } from "~/modules/emails/services/TransactionalEmailQueue.server";
|
||||
import { createStripeCustomer, isStripeConfigured } from "../stripe.server";
|
||||
import crypto from "crypto";
|
||||
import { createRegistration, getRegistrationByEmail, updateRegistration } from "../db/registration.db.server";
|
||||
import { db } from "~/utils/db.server";
|
||||
@@ -25,9 +24,9 @@ import { validatePassword as validatePolicyPassword } from "~/services/auth/pass
|
||||
import { verifyLeadToken } from "~/utils/leads/leadToken.server";
|
||||
import { recordExistingTenantLeadConversion } from "~/utils/leads/convertLead.server";
|
||||
import { createScopedLogger } from "~/utils/logger.server";
|
||||
import { resolveCaptchaConfig, verifyCaptchaToken, getSitekey, isCaptchaConfigured } from "@toolctrl/captcha";
|
||||
import { resolveCaptchaConfig, verifyCaptchaToken, getSecret, getSitekey, isCaptchaConfigured } from "@hivegrid/captcha";
|
||||
import { validateDesiredTenantSlug } from "./tenantService";
|
||||
import { seedShkRolesForTenant } from "./shkRoles.server";
|
||||
import { provisionShkTenantDefaults } from "./.server/akP20OnboardingService";
|
||||
|
||||
const authServiceLogger = createScopedLogger("auth-service");
|
||||
|
||||
@@ -52,7 +51,7 @@ export type RegistrationData = {
|
||||
leadId?: string;
|
||||
leadToken?: string;
|
||||
leadPlanId?: string;
|
||||
/** mCaptcha proof-of-work token from the client widget (hidden `mcaptcha__token` field). */
|
||||
/** Captcha token from the client widget (hidden `cap-token` or `mcaptcha__token` field). */
|
||||
captchaToken?: string;
|
||||
};
|
||||
|
||||
@@ -67,7 +66,7 @@ export async function getRegistrationFormData(request: Request): Promise<Registr
|
||||
const leadId = formData.get("leadId")?.toString().trim() || undefined;
|
||||
const leadToken = formData.get("leadToken")?.toString().trim() || undefined;
|
||||
const leadPlanId = formData.get("leadPlanId")?.toString().trim() || undefined;
|
||||
const captchaToken = formData.get("mcaptcha__token")?.toString().trim() || undefined;
|
||||
const captchaToken = formData.get("cap-token")?.toString().trim() || formData.get("mcaptcha__token")?.toString().trim() || undefined;
|
||||
|
||||
const ipError = await IpAddressServiceServer.log(request, {
|
||||
action: "register",
|
||||
@@ -114,13 +113,11 @@ export async function validateRegistration({
|
||||
registrationData,
|
||||
addToTrialOrFreePlan,
|
||||
checkEmailVerification = true,
|
||||
stripeCustomerId,
|
||||
}: {
|
||||
request: Request;
|
||||
registrationData: RegistrationData;
|
||||
addToTrialOrFreePlan: boolean;
|
||||
checkEmailVerification?: boolean;
|
||||
stripeCustomerId?: string;
|
||||
}) {
|
||||
const { t } = await getTranslations(request);
|
||||
const userInfo = await getUserInfo(request);
|
||||
@@ -130,7 +127,7 @@ export async function validateRegistration({
|
||||
throw Error(t("account.register.errors.invalidEmail"));
|
||||
}
|
||||
|
||||
// Anti-spam: verify the mCaptcha PoW token for human signups (email/password is
|
||||
// Anti-spam: verify the captcha token for human signups (email/password is
|
||||
// the only signup path after EU-Sterilisation removed social OAuth). No-op when
|
||||
// captcha is unconfigured; verification fails open if the instance is unreachable
|
||||
// (CAPTCHA_FAIL_OPEN).
|
||||
@@ -139,8 +136,9 @@ export async function validateRegistration({
|
||||
const captchaOk = await verifyCaptchaToken({
|
||||
token: registrationData.captchaToken,
|
||||
sitekey: getSitekey(captcha, "login"),
|
||||
secret: captcha.accountSecret,
|
||||
secret: getSecret(captcha, "login"),
|
||||
instanceUrl: captcha.instanceUrl,
|
||||
provider: captcha.provider,
|
||||
failOpen: captcha.failOpen,
|
||||
logger: authServiceLogger,
|
||||
});
|
||||
@@ -223,7 +221,6 @@ export async function validateRegistration({
|
||||
company,
|
||||
firstName,
|
||||
lastName,
|
||||
stripeCustomerId,
|
||||
avatarURL,
|
||||
locale,
|
||||
slug,
|
||||
@@ -345,7 +342,6 @@ interface CreateUserAndTenantDto {
|
||||
company?: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
stripeCustomerId?: string;
|
||||
avatarURL?: string;
|
||||
locale?: string;
|
||||
slug?: string;
|
||||
@@ -357,20 +353,12 @@ export async function createUserAndTenant({
|
||||
company,
|
||||
firstName,
|
||||
lastName,
|
||||
stripeCustomerId,
|
||||
avatarURL,
|
||||
locale,
|
||||
slug,
|
||||
}: CreateUserAndTenantDto) {
|
||||
let tenantName = company ?? email.split("@")[0];
|
||||
if (!stripeCustomerId && isStripeConfigured()) {
|
||||
const stripeCustomer = await createStripeCustomer(email, tenantName);
|
||||
if (!stripeCustomer) {
|
||||
throw Error("Could not create Stripe customer");
|
||||
}
|
||||
stripeCustomerId = stripeCustomer.id;
|
||||
}
|
||||
const tenant = await createTenant({ name: tenantName, subscriptionCustomerId: stripeCustomerId, slug });
|
||||
const tenant = await createTenant({ name: tenantName, slug });
|
||||
if (!tenant) {
|
||||
throw Error("Could not create tenant");
|
||||
}
|
||||
@@ -397,12 +385,13 @@ export async function createUserAndTenant({
|
||||
roles
|
||||
);
|
||||
await TenantTypesApi.setTenantTypes({ tenantId: tenant.id });
|
||||
// R-P2b — neuen (SHK-)Tenant mit den SHK-Standard-Rollen-Templates bestuecken. Best-effort:
|
||||
// ein Seed-Fehler darf die Registrierung nicht blockieren (Rollen sind anpassbar/nachseedbar).
|
||||
await seedShkRolesForTenant(tenant.id).catch((error: unknown) => {
|
||||
// AK-P20 — new SHK tenants get baseline roles, project pipeline, and first steps.
|
||||
// Best-effort: provisioning can be re-run later and must not block signup.
|
||||
const { t } = await getTranslations(request);
|
||||
await provisionShkTenantDefaults({ tenantId: tenant.id, userId: user.id, t }).catch((error: unknown) => {
|
||||
authServiceLogger.warn(
|
||||
{ op: "register.seedShkRoles.failed", tenantId: tenant.id, err: { name: error instanceof Error ? error.name : "Error" } },
|
||||
"Tenant created but SHK standard roles could not be seeded; they can be re-seeded later."
|
||||
{ op: "register.provisionShkDefaults.failed", tenantId: tenant.id, err: { name: error instanceof Error ? error.name : "Error" } },
|
||||
"Tenant created but SHK defaults could not be provisioned; they can be re-run later."
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user