diff --git a/src/middleware/pnid.ts b/src/middleware/pnid.ts index cb9776e..63b8554 100644 --- a/src/middleware/pnid.ts +++ b/src/middleware/pnid.ts @@ -6,6 +6,7 @@ import { HydratedPNIDDocument } from '@/types/mongoose/pnid'; async function PNIDMiddleware(request: express.Request, response: express.Response, next: express.NextFunction): Promise { const authHeader = getValueFromHeaders(request.headers, 'authorization'); + const email = getValueFromHeaders(request.headers, 'x-nintendo-email'); if (!authHeader || !(authHeader.startsWith('Bearer') || authHeader.startsWith('Basic'))) { return next(); @@ -53,6 +54,19 @@ async function PNIDMiddleware(request: express.Request, response: express.Respon return; } + if (email != undefined && pnid.email.address !== email) { + response.status(401).send(xmlbuilder.create({ + errors: { + error: { + code: '1105', + message: 'Email address, username, or password, is not valid' + } + } + }).end()); + + return; + } + if (pnid.deleted) { response.status(400).send(xmlbuilder.create({ errors: { @@ -84,4 +98,4 @@ async function PNIDMiddleware(request: express.Request, response: express.Respon return next(); } -export default PNIDMiddleware; \ No newline at end of file +export default PNIDMiddleware;