password reset

This commit is contained in:
2020-09-10 18:11:58 +02:00
parent f304463b46
commit 4d2d62d777
7 changed files with 87 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
import Restaurant from "../models/restaurant.js";
import {} from "./dataPrepServices.js";
import crypto from "crypto";
import Dish from "../models/dish.js";
import User from "../models/users.js";
import mongoose from "mongoose";
@@ -59,6 +59,22 @@ export function generateAuthToken(user) {
return token;
}
function generatePasswordResetToken(email) {
const token = jwt.sign(
{
email: email,
},
jwtSecret,
{ expiresIn: "15m" }
);
return token;
}
export function generatePasswordResetLink(email) {
const token = generatePasswordResetToken(email);
const link = `htt`;
}
export async function checkEmailTaken(email) {
if (!email) throw newError("No input email", 204);
await User.exists({ email: email }).then((res) => {