blah
This commit is contained in:
@ -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};
|
||||
|
@ -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
|
||||
};
|
Reference in New Issue
Block a user