feat: manage expert access and merge Parsian expert seeds

Allow role-specific identities and admin account activation, support national-code-only claim experts, and remove required voice from v4/v5. Add a combined, resumable Parsian seed that preserves existing accounts and merges locations and product codes.
This commit is contained in:
SepehrYahyaee
2026-11-18 17:16:26 +03:30
parent 2cdbc35d2e
commit 83376df4ad
38 changed files with 3608 additions and 136 deletions
@@ -29,7 +29,9 @@ export class CallCenterAgentDbService {
async findByLoginIdentifier(
identifier: string,
): Promise<CallCenterAgentModel | null> {
const id = identifier.trim();
const id = identifier.includes("@")
? identifier.trim().toLowerCase()
: identifier.trim();
const or: FilterQuery<CallCenterAgentModel>[] = [
{ email: id },
{ username: id },
@@ -25,7 +25,9 @@ export class FieldExpertDbService {
async findByLoginIdentifier(
identifier: string,
): Promise<FieldExpertModel | null> {
const id = identifier.trim();
const id = identifier.includes("@")
? identifier.trim().toLowerCase()
: identifier.trim();
const or: FilterQuery<FieldExpertModel>[] = [
{ email: id },
{ username: id },
@@ -25,7 +25,9 @@ export class FileMakerDbService {
async findByLoginIdentifier(
identifier: string,
): Promise<FileMakerModel | null> {
const id = identifier.trim();
const id = identifier.includes("@")
? identifier.trim().toLowerCase()
: identifier.trim();
const or: FilterQuery<FileMakerModel>[] = [{ email: id }, { username: id }];
if (/^\d{10}$/.test(id)) {
or.push({ nationalCode: id });
@@ -25,7 +25,9 @@ export class FileReviewerDbService {
async findByLoginIdentifier(
identifier: string,
): Promise<FileReviewerModel | null> {
const id = identifier.trim();
const id = identifier.includes("@")
? identifier.trim().toLowerCase()
: identifier.trim();
const or: FilterQuery<FileReviewerModel>[] = [
{ email: id },
{ username: id },
@@ -14,6 +14,9 @@ import { RoleEnum } from "src/Types&Enums/role.enum";
export class CallCenterAgentModel {
_id?: Types.ObjectId;
@Prop({ type: Boolean, default: true })
isActive?: boolean;
@Prop({ required: true })
firstName: string;
@@ -8,7 +8,6 @@ import {
import { RoleEnum } from "src/Types&Enums/role.enum";
import { UserType } from "src/Types&Enums/userType.enum";
@Schema({ _id: false, versionKey: false })
export class DamageExpertLocationModel {
@Prop({ type: String, required: true })
@@ -100,6 +99,9 @@ const FinancialInfoSchema = SchemaFactory.createForClass(FinancialInfo);
@Schema({ collection: "damage-expert", versionKey: false, timestamps: true })
export class DamageExpertModel {
@Prop({ type: Boolean, default: true })
isActive?: boolean;
@Prop({ required: true })
userType: UserType;
@@ -115,8 +117,8 @@ export class DamageExpertModel {
@Prop({ unique: true })
nationalCode: string;
@Prop({ type: "string", unique: true })
email: string;
@Prop({ type: String, unique: true, sparse: true })
email?: string;
@Prop({ type: "string" })
username: string;
@@ -124,8 +126,8 @@ export class DamageExpertModel {
@Prop({ required: true })
password: string;
@Prop({ required: true })
mobile: string;
@Prop({ required: false })
mobile?: string;
@Prop({ required: false })
phone?: string;
@@ -175,7 +177,7 @@ export class DamageExpertModel {
@Prop({ type: "string" })
city: string;
@Prop({type: "string", required: false})
@Prop({ type: "string", required: false })
expertCode?: string;
@Prop({ type: String, required: false })
@@ -198,7 +200,7 @@ export const DamageExpertDbSchema =
DamageExpertDbSchema.pre("save", function (next) {
if (!this.username) {
this.username = this.email;
this.username = this.email || this.nationalCode;
}
next();
});
});
+4 -1
View File
@@ -18,6 +18,9 @@ export const ExpertLocationDbSchema =
@Schema({ collection: "expert", versionKey: false, timestamps: true })
export class ExpertModel {
@Prop({ type: Boolean, default: true })
isActive?: boolean;
@Prop({})
firstName: string;
@@ -87,7 +90,7 @@ export class ExpertModel {
@Prop({ type: "string" })
otp: string;
@Prop({type: "string", required: false})
@Prop({ type: "string", required: false })
expertCode?: string;
@Prop({ type: String, required: false })
@@ -23,6 +23,9 @@ export const FieldExpertLocationDbSchema = SchemaFactory.createForClass(
export class FieldExpertModel {
_id?: Types.ObjectId;
@Prop({ type: Boolean, default: true })
isActive?: boolean;
@Prop({ required: true })
firstName: string;
@@ -71,7 +74,7 @@ export class FieldExpertModel {
@Prop({ type: "string", default: "" })
otp: string;
@Prop({type: "string", required: false})
@Prop({ type: "string", required: false })
expertCode?: string;
@Prop({ type: String, required: false })
@@ -23,6 +23,9 @@ export const FileMakerLocationDbSchema = SchemaFactory.createForClass(
export class FileMakerModel {
_id?: Types.ObjectId;
@Prop({ type: Boolean, default: true })
isActive?: boolean;
@Prop({ required: true })
firstName: string;
@@ -23,6 +23,9 @@ export const FileReviewerLocationDbSchema = SchemaFactory.createForClass(
export class FileReviewerModel {
_id?: Types.ObjectId;
@Prop({ type: Boolean, default: true })
isActive?: boolean;
@Prop({ required: true })
firstName: string;