MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / seedVerifiedUser

Function seedVerifiedUser

apps/api/tests/helpers/auth.ts:52–92  ·  view source on GitHub ↗
(
  input: ISeedVerifiedUserInput
)

Source from the content-addressed store, hash-verified

50 * actually exercising those routes.
51 */
52export const seedVerifiedUser = async (
53 input: ISeedVerifiedUserInput
54): Promise<ISeedVerifiedUserResult> => {
55 const password = input.password ?? DEFAULT_PASSWORD;
56 const passwordHash = await passwordService.hash(password);
57 const verifiedAt = now();
58 const normalizedEmail = normalizeEmail(input.email);
59
60 const [user] = await db
61 .insert(users)
62 .values({
63 email: normalizedEmail,
64 firstName: input.firstName ?? "",
65 lastName: input.lastName ?? "",
66 emailVerifiedAt: verifiedAt,
67 isPlatformAdmin: input.isPlatformAdmin ?? false,
68 })
69 .returning();
70
71 if (!user) {
72 throw new Error("seedVerifiedUser: failed to insert user row");
73 }
74
75 await db.insert(userAuthProviders).values({
76 userId: user.id,
77 provider: EMAIL_PROVIDER_KEY,
78 providerUserId: normalizedEmail,
79 passwordHash,
80 });
81
82 const provisioned = await accountsService.provisionAfterVerification({
83 userId: user.id,
84 });
85
86 return {
87 user,
88 account: provisioned.account,
89 membership: provisioned.membership,
90 password,
91 };
92};
93
94/**
95 * Fixture for tests that exercise the pending-user state. Inserts the

Callers 15

registerAndLoginFunction · 0.90
registerAndLoginFunction · 0.90
seedUserFunction · 0.90
registerAndLoginFunction · 0.90
mfa.routes.test.tsFile · 0.90
seedUserFunction · 0.90

Calls 4

nowFunction · 0.90
normalizeEmailFunction · 0.90
hashMethod · 0.80

Tested by 9

registerAndLoginFunction · 0.72
registerAndLoginFunction · 0.72
seedUserFunction · 0.72
registerAndLoginFunction · 0.72
seedUserFunction · 0.72
seedUserFunction · 0.72
registerAndLoginFunction · 0.72
registerAndLoginFunction · 0.72