Implement user registration and email verification features
This commit is contained in:
@@ -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,
|
||||
};
|
||||
Reference in New Issue
Block a user