MCPcopy
hub / github.com/fosrl/pangolin / generateEmailVerificationCode

Function generateEmailVerificationCode

server/auth/sendEmailVerificationCode.ts:30–48  ·  view source on GitHub ↗
(
    userId: string,
    email: string
)

Source from the content-addressed store, hash-verified

28}
29
30async function generateEmailVerificationCode(
31 userId: string,
32 email: string
33): Promise<string> {
34 const code = generateRandomString(8, alphabet("0-9"));
35 await db.transaction(async (trx) => {
36 await trx
37 .delete(emailVerificationCodes)
38 .where(eq(emailVerificationCodes.userId, userId));
39
40 await trx.insert(emailVerificationCodes).values({
41 userId,
42 email,
43 code,
44 expiresAt: createDate(new TimeSpan(15, "m")).getTime()
45 });
46 });
47 return code;
48}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected