chore: change the login and regitster flow to single route
This commit is contained in:
@@ -1 +1 @@
|
||||
export type OtpCacheKeyType = "LOGIN" | "REGISTER" | "FORGOT_PASSWORD" | "INVOICE_VERIFY";
|
||||
export type OtpCacheKeyType = "LOGIN/REGISTER" | "FORGOT_PASSWORD" | "INVOICE_VERIFY";
|
||||
|
||||
@@ -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("");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user