mirror of
https://github.com/PretendoNetwork/BOSS.git
synced 2026-03-21 17:34:19 -05:00
Revert "refactor: remove authentication middleware - unneeded and caused eslint to complain"
This reverts commit ab0a6cc151.
This commit is contained in:
parent
9bebbe6e05
commit
eb2585d33b
11
src/middleware/authentication.ts
Normal file
11
src/middleware/authentication.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { getNEXDataByPID } from '@/util';
|
||||
import type express from 'express';
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ 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';
|
||||
|
|
@ -28,6 +29,7 @@ app.use(express.urlencoded({
|
|||
}));
|
||||
|
||||
app.use(parseUserAgentMiddleware);
|
||||
app.use(authenticationMiddleware);
|
||||
|
||||
app.use(nppl);
|
||||
app.use(npts);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import express from 'express';
|
|||
import subdomain from 'express-subdomain';
|
||||
import Dicer from 'dicer';
|
||||
import { getDuplicateCECData, getRandomCECData } from '@/database';
|
||||
import { getFriends, getNEXDataByPID } from '@/util';
|
||||
import { getFriends } from '@/util';
|
||||
import { CECData } from '@/models/cec-data';
|
||||
import { CECSlot } from '@/models/cec-slot';
|
||||
import { SendMode } from '@/types/common/spr-slot';
|
||||
|
|
@ -70,19 +70,13 @@ spr.post('/relay/0', multipartParser, async (request, response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!request.pid) {
|
||||
response.sendStatus(400);
|
||||
return;
|
||||
}
|
||||
|
||||
const nexAccount = await getNEXDataByPID(request.pid);
|
||||
if (!nexAccount) {
|
||||
if (!request.pid || !request.nexAccount) {
|
||||
response.sendStatus(400);
|
||||
return;
|
||||
}
|
||||
|
||||
// * Check that the account is a 3DS and isn't banned
|
||||
if (!nexAccount.friendCode || nexAccount.accessLevel < 0) {
|
||||
if (!request.nexAccount.friendCode || request.nexAccount.accessLevel < 0) {
|
||||
response.sendStatus(400);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
13
src/types/express.d.ts
vendored
13
src/types/express.d.ts
vendored
|
|
@ -1,6 +1,11 @@
|
|||
declare namespace Express {
|
||||
interface Request {
|
||||
files?: Record<string, any>;
|
||||
pid: number;
|
||||
import type { GetNEXDataResponse } from '@pretendonetwork/grpc/account/get_nex_data_rpc';
|
||||
|
||||
declare global {
|
||||
namespace Express {
|
||||
interface Request {
|
||||
files?: Record<string, any>;
|
||||
pid: number;
|
||||
nexAccount: GetNEXDataResponse | null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user