Download src/models/Otp.ts from lynfera/api: direct link, hf CLI and curl.
- Browser
- Download file 896 Bytes
-
https://huggingface.co/spaces/lynfera/api/resolve/main/src/models/Otp.ts
- Command line
-
hf download hf://spaces/lynfera/api/src/models/Otp.ts
-
curl -L -o Otp.ts https://huggingface.co/spaces/lynfera/api/resolve/main/src/models/Otp.ts
896 Bytes
| import mongoose, { Document, Schema, Types } from "mongoose"; | |
| export enum OtpPurposes { | |
| SIGNUP = "SIGNUP", | |
| RESET_PASSWORD = "RESET_PASSWORD", | |
| LOGIN = "LOGIN", | |
| } | |
| export interface IOtp extends Document { | |
| userId: Types.ObjectId | string; | |
| otpHash: string; | |
| expiresAt: Date; | |
| attempts: number; | |
| resentCount: number; | |
| purpose: OtpPurposes; | |
| createdAt: Date; | |
| updatedAt: Date; | |
| } | |
| const OtpSchema = new Schema<IOtp>( | |
| { | |
| userId: { type: Schema.Types.ObjectId, ref: "User", required: true }, | |
| otpHash: { type: String, required: true }, | |
| expiresAt: { type: Date, required: true }, | |
| resentCount: { type: Number, default: 0 }, | |
| purpose: { | |
| type: String, | |
| enum: Object.values(OtpPurposes), | |
| required: true, | |
| default: OtpPurposes.SIGNUP, | |
| }, | |
| attempts: { type: Number, default: 0 }, | |
| }, | |
| { timestamps: true }, | |
| ); | |
| export const OtpModel = mongoose.model<IOtp>("OtpVerification", OtpSchema); | |