use findOneAndDelete to make sure tokens are deleted when used

This commit is contained in:
Alex Holliday committed 2024-07-23 14:37:15 -07:00
1 parent 608153b461
commit aa6260af85
1 file changed
+1 -3
+1 -3
View File
@@ -172,7 +172,6 @@ const getAllUsers = async (req, res) => {
const requestInviteToken = async (req, res) => { const requestInviteToken = async (req, res) => {
try { try {
console.log(req.body.role);
await InviteToken.deleteMany({ email: req.body.email }); await InviteToken.deleteMany({ email: req.body.email });
let inviteToken = new InviteToken({ let inviteToken = new InviteToken({
email: req.body.email, email: req.body.email,
@@ -188,8 +187,7 @@ const requestInviteToken = async (req, res) => {
const getInviteToken = async (req, res) => { const getInviteToken = async (req, res) => {
try { try {
console.log(req.body.token); const invite = await InviteToken.findOneAndDelete({
const invite = await InviteToken.findOne({
token: req.body.token, token: req.body.token,
}); });
if (invite === null) { if (invite === null) {