Skip to content

Commit

Permalink
update code size
Browse files Browse the repository at this point in the history
  • Loading branch information
Janderson Souza Matias authored and Janderson Souza Matias committed Jan 15, 2024
1 parent cfab700 commit 2255eec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/modules/auth/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class AuthenticationController {
return res.status(404).send({ user });
}

await Authentication.sendEmailOTP(user.email);
await Authentication.sendEmailOTP(user.email, 8);

return res.status(200).send(email);
}
Expand Down
13 changes: 11 additions & 2 deletions src/modules/auth/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,19 @@ export default class Authentication {
}
};

public static sendEmailOTP = async (email: string) => {
public static generateOTPCode = (size: number) => {
let code = "";
for (let i = 0; i < size; i++) {
code += Math.floor(Math.random() * 10).toString();
}
return code;
};

public static sendEmailOTP = async (email: string, size = 6) => {
sgMail.setApiKey(process.env.SENDGRID_API_KEY || "");

const code = Math.floor(1000 + Math.random() * 9000).toString();
const code = this.generateOTPCode(size);

const msg = {
to: email,
from: "[email protected]",
Expand Down

0 comments on commit 2255eec

Please sign in to comment.