MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / create

Method create

lib/models/user.ts:234–270  ·  view source on GitHub ↗
(
    user: User,
    verificationId: string,
    type: VerificationCode['verification']['type'],
  )

Source from the content-addressed store, hash-verified

232
233export class VerificationCodeModel {
234 static async create(
235 user: User,
236 verificationId: string,
237 type: VerificationCode['verification']['type'],
238 ) {
239 const inThirtyMinutes = new Date(new Date().setUTCMinutes(new Date().getUTCMinutes() + 30));
240
241 const code = generateRandomCode();
242
243 const newVerificationCode: Omit<VerificationCode, 'id' | 'created_at'> = {
244 user_id: user.id,
245 code,
246 expires_at: inThirtyMinutes,
247 verification: {
248 id: verificationId,
249 type,
250 },
251 };
252
253 await db.query(
254 sql`INSERT INTO "bewcloud_verification_codes" (
255 "user_id",
256 "code",
257 "expires_at",
258 "verification"
259 ) VALUES ($1, $2, $3, $4)
260 RETURNING "id"`,
261 [
262 newVerificationCode.user_id,
263 newVerificationCode.code,
264 newVerificationCode.expires_at,
265 JSON.stringify(newVerificationCode.verification),
266 ],
267 );
268
269 return code;
270 }
271
272 static async validate(
273 user: User,

Callers

nothing calls this directly

Calls 2

generateRandomCodeFunction · 0.90
queryMethod · 0.80

Tested by

no test coverage detected