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

Function seedPendingUser

apps/api/tests/helpers/auth.ts:99–127  ·  view source on GitHub ↗
(
  input: ISeedPendingUserInput
)

Source from the content-addressed store, hash-verified

97 * No account or membership is created; that's the whole point.
98 */
99export const seedPendingUser = async (
100 input: ISeedPendingUserInput
101): Promise<ISeedPendingUserResult> => {
102 const password = input.password ?? DEFAULT_PASSWORD;
103 const passwordHash = await passwordService.hash(password);
104 const normalizedEmail = normalizeEmail(input.email);
105
106 const [user] = await db
107 .insert(users)
108 .values({
109 email: normalizedEmail,
110 firstName: input.firstName ?? "",
111 lastName: input.lastName ?? "",
112 })
113 .returning();
114
115 if (!user) {
116 throw new Error("seedPendingUser: failed to insert user row");
117 }
118
119 await db.insert(userAuthProviders).values({
120 userId: user.id,
121 provider: EMAIL_PROVIDER_KEY,
122 providerUserId: normalizedEmail,
123 passwordHash,
124 });
125
126 return { user, password };
127};

Callers 4

seedUserFunction · 0.90

Calls 2

normalizeEmailFunction · 0.90
hashMethod · 0.80

Tested by 1

seedUserFunction · 0.72