diff --git a/controllers/scoreController.ts b/controllers/scoreController.ts index 3cb83d5..48e938f 100644 --- a/controllers/scoreController.ts +++ b/controllers/scoreController.ts @@ -81,6 +81,8 @@ module.exports.checkout_post = async (req: any, res: any) => { checkoutId, } = req.body; + const { isAdmin, isPlaywright } = res.locals.user; + try { if (userId && scoreId) { let score = await Score.findOne({ id: scoreId }); @@ -115,7 +117,7 @@ module.exports.checkout_post = async (req: any, res: any) => { score = await score.save(); if (score) { const user = await User.findOne({ id: userId }); - if (user) { + if (user && !isPlaywright) { // we don't expect error because we validated the user id before await sendCheckoutConfirmationEmail( user, @@ -214,6 +216,7 @@ module.exports.checkout_post = async (req: any, res: any) => { module.exports.checkin_post = async (req: any, res: any) => { const { scoreId, comment } = req.body; + const { isAdmin, isPlaywright } = res.locals.user; try { if (scoreId && comment != undefined) { @@ -240,16 +243,18 @@ module.exports.checkin_post = async (req: any, res: any) => { score = await score.save(); if (score) { - await sendCheckinConfirmationEmail( - user, - score, - process.env.EMAIL_TEST_RECIPIENT - ); + if (!isPlaywright) { + await sendCheckinConfirmationEmail( + user, + score, + process.env.EMAIL_TEST_RECIPIENT + ); + } res.status(201).json({ checkinScore: score }); } else { res .status(400) - .json({ errors: "Update score with checkout record failed" }); + .json({ errors: "Update score checkout record for checkin failed" }); } } else { res.status(400).json({ diff --git a/dist/controllers/scoreController.js b/dist/controllers/scoreController.js index 1e33dec..6127fcd 100644 --- a/dist/controllers/scoreController.js +++ b/dist/controllers/scoreController.js @@ -73,6 +73,7 @@ module.exports.checkout_get = (req, res) => { }; module.exports.checkout_post = (req, res) => __awaiter(void 0, void 0, void 0, function* () { const { userJwtOrCheckoutId, userId, userLastName, scoreId, scoreExtId, state, date, comment, allowDoubleCheckout, checkoutId, } = req.body; + const { isAdmin, isPlaywright } = res.locals.user; try { if (userId && scoreId) { let score = yield Score_1.Score.findOne({ id: scoreId }); @@ -99,7 +100,7 @@ module.exports.checkout_post = (req, res) => __awaiter(void 0, void 0, void 0, f score = yield score.save(); if (score) { const user = yield User_1.User.findOne({ id: userId }); - if (user) { + if (user && !isPlaywright) { // we don't expect error because we validated the user id before yield sendCheckoutConfirmationEmail(user, score, process.env.EMAIL_TEST_RECIPIENT); } @@ -201,6 +202,7 @@ module.exports.checkout_post = (req, res) => __awaiter(void 0, void 0, void 0, f }); module.exports.checkin_post = (req, res) => __awaiter(void 0, void 0, void 0, function* () { const { scoreId, comment } = req.body; + const { isAdmin, isPlaywright } = res.locals.user; try { if (scoreId && comment != undefined) { // checkin request @@ -226,13 +228,15 @@ module.exports.checkin_post = (req, res) => __awaiter(void 0, void 0, void 0, fu checkout.checkinComment = comment; score = yield score.save(); if (score) { - yield sendCheckinConfirmationEmail(user, score, process.env.EMAIL_TEST_RECIPIENT); + if (!isPlaywright) { + yield sendCheckinConfirmationEmail(user, score, process.env.EMAIL_TEST_RECIPIENT); + } res.status(201).json({ checkinScore: score }); } else { res .status(400) - .json({ errors: "Update score with checkout record failed" }); + .json({ errors: "Update score checkout record for checkin failed" }); } } else { diff --git a/dist/models/User.js b/dist/models/User.js index d90888a..16e2eb4 100644 --- a/dist/models/User.js +++ b/dist/models/User.js @@ -94,6 +94,10 @@ const userSchema = new mongoose_1.Schema({ type: Boolean, default: false, }, + isPlaywright: { + type: Boolean, + default: false, + }, active: { type: Boolean, default: true, diff --git a/models/User.ts b/models/User.ts index a08ed2d..ae175a8 100644 --- a/models/User.ts +++ b/models/User.ts @@ -41,6 +41,7 @@ export interface IUser { isAdmin: boolean; isManuallyRegistered: boolean; isPasswordHashed: boolean; + isPlaywright: boolean; active: boolean; } @@ -109,6 +110,10 @@ const userSchema = new Schema({ type: Boolean, default: false, }, + isPlaywright: { + type: Boolean, + default: false, + }, active: { type: Boolean, default: true, diff --git a/package.json b/package.json index e055f32..cd447c2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "typescript": "^5.2.2" }, "scripts": { - "start": "node dist/app.js", + "start": "ts-node app.ts", "dev": "nodemon app.ts", "pretty-quick": "pretty-quick" }, diff --git a/views/not-verified.ejs b/views/not-verified.ejs index 295d691..c1b997f 100644 --- a/views/not-verified.ejs +++ b/views/not-verified.ejs @@ -2,7 +2,7 @@

Benutzer nicht verifiziert

-Deine E-Mail Adresse wurde noch nicht veriziert. Du kannst dir hier einen neuen Link zur Verifizierung zusenden lassen. +Deine E-Mail Adresse wurde noch nicht verifiziert. Du kannst dir hier einen neuen Link zur Verifizierung zusenden lassen.