recovery
This commit is contained in:
1 parent
cb5b8e0673
commit
9c92542653
12 files changed
+154
-36
No files matched your search
@@ -1,25 +0,0 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const RecoveryTokenSchema = mongoose.Schema(
|
||||
{
|
||||
email: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
token: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
expiry: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
expires: 600,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
);
|
||||
|
||||
export default mongoose.model("RecoveryToken", RecoveryTokenSchema);
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Schema, model, type Types } from "mongoose";
|
||||
import type { RecoveryToken as RecoveryTokenEntity } from "@/types/recoveryToken.js";
|
||||
|
||||
type RecoveryTokenDocumentBase = Omit<RecoveryTokenEntity, "id" | "createdAt" | "updatedAt" | "expiry"> & {
|
||||
expiry: Date;
|
||||
};
|
||||
|
||||
interface RecoveryTokenDocument extends RecoveryTokenDocumentBase {
|
||||
_id: Types.ObjectId;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
const RecoveryTokenSchema = new Schema<RecoveryTokenDocument>(
|
||||
{
|
||||
email: { type: String, required: true, unique: true },
|
||||
token: { type: String, required: true },
|
||||
expiry: { type: Date, default: Date.now, expires: 600 },
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
const RecoveryTokenModel = model<RecoveryTokenDocument>("RecoveryToken", RecoveryTokenSchema);
|
||||
|
||||
export type { RecoveryTokenDocument };
|
||||
export { RecoveryTokenModel };
|
||||
export default RecoveryTokenModel;
|
||||
@@ -15,3 +15,6 @@ export { default as UserModel } from "@/db/models/User.js";
|
||||
|
||||
export * from "@/db/models/Invite.js";
|
||||
export { default as InviteModel } from "@/db/models/Invite.js";
|
||||
|
||||
export * from "@/db/models/RecoveryToken.js";
|
||||
export { default as RecoveryTokenModel } from "@/db/models/RecoveryToken.js";
|
||||
Reference in new issue
Block a user