refactor: change the role to roles and many to many

This commit is contained in:
mahyargdz
2025-02-16 16:58:51 +03:30
parent 9cdd7ef28e
commit ad673613d9
32 changed files with 264 additions and 88 deletions
+1 -3
View File
@@ -23,6 +23,4 @@ export interface ISmsVerifyBody {
TemplateId: string;
}
// export type SmsBodyType = ISmsVerifyBody;
export type TemplateParams = "Code";
export type TemplateParams = "VERIFICATIONCODE";
@@ -0,0 +1,7 @@
import { Role } from "../../users/entities/role.entity";
import { RoleEnum } from "../../users/enums/role.enum";
export function checkUserRole(userRoles: Role[], requiredRole: RoleEnum) {
if (!userRoles.some((role) => role.name === requiredRole)) return false;
return true;
}
+2 -2
View File
@@ -20,7 +20,7 @@ export class SmsService {
async sendSmsVerifyCode(mobile: string, otpCode: string) {
//
const smsData: ISmsVerifyBody = {
Parameters: [{ name: "Code", value: otpCode }],
Parameters: [{ name: "VERIFICATIONCODE", value: otpCode }],
Mobile: mobile,
TemplateId: this.smsConfigs.SMS_PATTERN_OTP,
};
@@ -30,7 +30,7 @@ export class SmsService {
this.httpService
.post<ISmsVerifyResponse>(
`${this.smsConfigs.API_URL}/send/verify`,
{ smsData },
{ ...smsData },
{
headers: { "X-API-KEY": this.smsConfigs.API_KEY },
},