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
@@ -0,0 +1,46 @@
//app/models/user/emailVerification.model.js
module.exports = (sequelize, DataTypes) => {
const EmailVerification = sequelize.define(
"EmailVerification",
{
id: {
type: DataTypes.STRING,
primaryKey: true,
},
user_id: {
type: DataTypes.STRING,
allowNull: false,
},
tokenHash: {
type: DataTypes.STRING,
allowNull: false,
},
expiresAt: {
type: DataTypes.DATE,
allowNull: false,
},
usedAt: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: null,
},
},
{
tableName: "email_verifications",
timestamps: true,
}
);
EmailVerification.associate = (db) => {
EmailVerification.belongsTo(db.User, {
foreignKey: "user_id",
as: "user",
});
};
return EmailVerification;
};