Implement user registration and email verification features

This commit is contained in:
Isuru Bimsara
2026-08-17 16:52:44 +05:30
parent ef8db0988b
commit c3d9f899a1
11 changed files with 781 additions and 53 deletions
+28
View File
@@ -0,0 +1,28 @@
//app/utils/emailVerification.util.js
const crypto = require("crypto");
/**
* Generate a cryptographically secure
* random email-verification token.
*/
const generateEmailVerificationToken = () => {
return crypto.randomBytes(32).toString("hex");
};
/**
* Hash verification token before
* storing it in database.
*/
const hashEmailVerificationToken = (token) => {
return crypto
.createHash("sha256")
.update(token)
.digest("hex");
};
module.exports = {
generateEmailVerificationToken,
hashEmailVerificationToken,
};