This commit is contained in:
noot
2024-01-30 15:58:05 +08:00
parent 884209ee9c
commit 4346f92471
10 changed files with 2357 additions and 1119 deletions

View File

@ -50,6 +50,21 @@ async function addToken(userId, permission, isKey ,expiry) {
return token.id + "-" + uuid;
}
async function addPasswordResetToken(data , token){
let hashtoken = await hash(uuid);
let currentDate = new Date();
let tokenToLive = new Date(currentDate.getTime() + 15 * 60000);
let tokenRes = await tokenModel.create({
userid: data.id,
token: hashtoken,
permission: "canRead",
isKey: "isNotKey",
expiration: tokenToLive,
});
return true;
}
async function checkToken(id) {
let tokenRes = await tokenModel.findOne(
{
@ -62,4 +77,6 @@ async function checkToken(id) {
return tokenRes;
}
module.exports = { addToken, getTokenByToken , checkToken};
module.exports = { addToken, getTokenByToken , checkToken , addPasswordResetToken};

View File

@ -152,6 +152,17 @@ async function checkEmail(email) {
}
async function checkEmailDetails(email) {
let emailRes = await userModel.findOne({
where: {
email: email,
},
});
if (!emailRes) return false;
return emailRes;
}
module.exports = {
getUserByID,
@ -159,5 +170,6 @@ module.exports = {
addUser,
loginUser,
updateProfile,
checkEmail
checkEmail,
checkEmailDetails
};