-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f255110
commit 0830dd5
Showing
8 changed files
with
207 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { PaginateModel } from 'mongoose' | ||
import { Injectable } from '@nestjs/common' | ||
import { InjectModel } from '@nestjs/mongoose' | ||
|
||
import { AbstractRepository } from '@common/repositories' | ||
import { Otp, OtpDocument } from '@auth/schema/otp.schema' | ||
|
||
@Injectable() | ||
export class OtpRepository extends AbstractRepository<OtpDocument> { | ||
constructor(@InjectModel(Otp.name) model: PaginateModel<OtpDocument>) { | ||
super(model) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose' | ||
import { HydratedDocument } from 'mongoose' | ||
import * as paginate from 'mongoose-paginate-v2' | ||
import { Transform } from 'class-transformer' | ||
|
||
export type OtpDocument = HydratedDocument<Otp> | ||
|
||
@Schema({ | ||
collection: 'otps', | ||
timestamps: { | ||
createdAt: true, | ||
updatedAt: true | ||
}, | ||
toJSON: { | ||
transform(doc, ret) { | ||
delete ret.__v | ||
} | ||
} | ||
}) | ||
export class Otp { | ||
constructor(id?: string) { | ||
this._id = id | ||
} | ||
@Transform(({ value }) => value?.toString()) | ||
_id: string | ||
|
||
@Prop({ type: String, required: true }) | ||
otp: string | ||
|
||
@Prop({ type: String, required: true, index: true }) | ||
customerId: string | ||
|
||
@Prop({ type: Date, required: true }) | ||
expiredAt: Date | ||
} | ||
|
||
export const OtpSchema = SchemaFactory.createForClass(Otp) | ||
|
||
OtpSchema.plugin(paginate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<pre style="font-family: Arial, Helvetica, sans-serif; font-size: 1.5em"> | ||
<h2>Email OTP</h2> | ||
<p>Xin chào,</p> | ||
<p>Mã OTP của bạn là: <%= otp %></p> | ||
<p>Vui lòng sử dụng mã OTP này để xác minh tài khoản của bạn.</p> | ||
<p>Cảm ơn bạn!</p> | ||
</pre> | ||
<%- include('web-footer') -%> |