WhisperNet / models /User.ts
bonesmasher's picture
Upload 56 files
abc1805 verified
raw
history blame contribute delete
732 Bytes
import mongoose, { Schema, Document } from "mongoose";
export interface IUser extends Document {
email: string;
password?: string;
image?: string;
twoFactorSecret?: string;
isTwoFactorEnabled: boolean;
createdAt: Date;
}
const UserSchema: Schema = new Schema({
email: { type: String, required: true, unique: true },
password: { type: String, required: false }, // Optional for OAuth, but we are using Credentials
image: { type: String },
twoFactorSecret: { type: String },
isTwoFactorEnabled: { type: Boolean, default: false },
createdAt: { type: Date, default: Date.now },
});
export default mongoose.models.User || mongoose.model<IUser>("User", UserSchema);