chore: change the login and regitster flow to single route

This commit is contained in:
mahyargdz
2025-08-16 12:50:58 +03:30
parent 629b8dbdd5
commit ef57dc7107
24 changed files with 340 additions and 235 deletions
+1 -1
View File
@@ -1 +1 @@
export type OtpCacheKeyType = "LOGIN" | "REGISTER" | "FORGOT_PASSWORD" | "INVOICE_VERIFY";
export type OtpCacheKeyType = "LOGIN/REGISTER" | "FORGOT_PASSWORD" | "INVOICE_VERIFY";
+2 -1
View File
@@ -48,4 +48,5 @@ export type TemplateParams =
| "message"
| "blogTitle"
| "fullName"
| "mobile";
| "mobile"
| "password";
@@ -789,5 +789,35 @@ export class SmsService {
}
}
async sendUserPasswordSms(mobile: string, password: string) {
const smsData: ISmsVerifyBody = {
Parameters: [{ name: "password", value: password }],
Mobile: mobile,
TemplateId: this.smsConfigs.SMS_PATTERN_USER_PASSWORD,
};
try {
const { data } = await firstValueFrom(
this.httpService
.post<ISmsVerifyResponse>(
`${this.smsConfigs.API_URL}/send/verify`,
{ ...smsData },
{
headers: { "X-API-KEY": this.smsConfigs.API_KEY },
},
)
.pipe(
catchError((err: AxiosError) => {
this.logger.error("error in sending user password sms", err);
throw new InternalServerErrorException("error in sending user password sms");
}),
),
);
return data;
} catch (error) {
this.logger.error("error in sending sms", error);
}
}
//************************************************* */
}
@@ -2,3 +2,19 @@ export function truncateIfLong(str: string, maxLength = 30): string {
if (typeof str !== "string") return str;
return str.length > maxLength ? str.slice(0, maxLength) + "..." : str;
}
export function randomizeCase(str: string): string {
if (typeof str !== "string") return str;
return str
.split("")
.map((char) => {
// Only process alphabetic characters
if (/[a-zA-Z]/.test(char)) {
// 50% chance to make it uppercase, 50% lowercase
return Math.random() < 0.5 ? char.toLowerCase() : char.toUpperCase();
}
return char; // Keep non-alphabetic characters as they are
})
.join("");
}