refactor: remove authentication middleware - unneeded and caused eslint to complain

This commit is contained in:
William Oldham 2025-01-08 12:55:54 +00:00
parent 7e37300884
commit ab0a6cc151
4 changed files with 12 additions and 26 deletions

View File

@ -1,11 +0,0 @@
import express from 'express';
import { getNEXDataByPID } from '@/util';
export default async function authenticationMiddleware(request: express.Request, response: express.Response, next: express.NextFunction): Promise<void> {
if (request.pid) {
// TODO - Get users PNIDs
request.nexAccount = await getNEXDataByPID(request.pid);
}
return next();
}

View File

@ -10,10 +10,7 @@ import { startGRPCServer } from '@/services/grpc/server';
import RequestException from '@/request-exception';
import { LOG_INFO, LOG_SUCCESS } from '@/logger';
import { config } from '@/config-manager';
import parseUserAgentMiddleware from '@/middleware/parse-user-agent';
import authenticationMiddleware from '@/middleware/authentication';
import nppl from '@/services/nppl';
import npts from '@/services/npts';
import npdi from '@/services/npdi';
@ -31,7 +28,6 @@ app.use(express.urlencoded({
}));
app.use(parseUserAgentMiddleware);
app.use(authenticationMiddleware);
app.use(nppl);
app.use(npts);

View File

@ -69,13 +69,19 @@ spr.post('/relay/0', multipartParser, async (request, response) => {
return;
}
if (!request.pid || !request.nexAccount) {
if (!request.pid) {
response.sendStatus(400);
return;
}
const nexAccount = await getNEXDataByPID(request.pid);
if (!nexAccount) {
response.sendStatus(400);
return;
}
// * Check that the account is a 3DS and isn't banned
if (!request.nexAccount.friendCode || request.nexAccount.accessLevel < 0) {
if (!nexAccount.friendCode || nexAccount.accessLevel < 0) {
response.sendStatus(400);
return;
}

View File

@ -1,11 +1,6 @@
import { GetNEXDataResponse } from '@pretendonetwork/grpc/account/get_nex_data_rpc';
declare global {
namespace Express {
interface Request {
files?: Record<string, any>;
pid: number;
nexAccount: GetNEXDataResponse | null;
}
declare namespace Express {
interface Request {
files?: Record<string, any>;
pid: number;
}
}