first commit v3 initialiazed a temporary repository for darmanet client

This commit is contained in:
2026-09-08 16:04:01 +03:30
commit 5c7fd95052
216 changed files with 30050 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
import * as crypto from 'node:crypto';
import { Prop, Schema } from '@nestjs/mongoose';
import { Role } from 'src/common/types/role.type';
@Schema()
export class UsersBaseModel {
@Prop()
name: string;
@Prop()
family: string;
@Prop({ required: true })
role: Role;
@Prop()
fatherName: string;
@Prop()
shenasnameseri: string;
@Prop()
shenasnameserial: string;
@Prop()
birthDate: string;
@Prop()
gender: string;
@Prop({
required: false,
match: /^[0-9]{11}$/,
default: undefined,
})
mobile: string;
@Prop()
birthday: string;
@Prop()
nationalCode: string;
@Prop({ match: /^((?!\.)[\w\-_.]*[^.])(@\w+)(\.\w+(\.\w+)?[^.\W])$/ })
email: string;
@Prop()
address: string;
@Prop({
default: function () {
// Generate 6-digit number or use mobile
return (
this.mobile || Math.floor(100000 + Math.random() * 900000).toString()
);
},
})
username: string;
@Prop({ type: Date })
last_login: Date;
@Prop({ type: Date, default: Date.now })
createdAt: Date;
@Prop({ type: Date, default: Date.now })
updatedAt: Date;
static validateOtp(otpInput: string, storedOtpHash: string): boolean {
const inputOtpHash = crypto
.createHash('sha256')
.update(otpInput)
.digest('hex');
return inputOtpHash === storedOtpHash;
}
}