Skip to content

Commit

Permalink
Added more checks to token middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbarrow committed Apr 3, 2023
1 parent 34c87d2 commit 5df025e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/middleware/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@ import express from 'express';
import { decryptAndUnpackToken, jsonEncodeUTF16LE } from '@/util';

function tokenMiddleware(request: express.Request, response: express.Response, next: express.NextFunction): void {
// * RPG Maker appends a single F character to each service token, for some reason
request.token = decryptAndUnpackToken(request.args.token.substring(1));
if (!request.token) {
response.send(jsonEncodeUTF16LE({
EndCode: 102
}));

return;
}

try {
// * RPG Maker appends a single F character to each service token, for some reason
request.token = decryptAndUnpackToken(request.args.token.substring(1));
} catch (error) {
response.send(jsonEncodeUTF16LE({
EndCode: 102
}));

return;
}

const expireTime: number = Math.floor((Number(request.token.expire_time) / 1000));

Expand Down

0 comments on commit 5df025e

Please sign in to comment.