/[sudobot]/branches/2.x/src/api/Auth.ts
ViewVC logotype

Annotation of /branches/2.x/src/api/Auth.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (hide annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 546 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 rakinar2 577 import { NextFunction, Request, Response } from "express";
2     import DiscordClient from "../client/Client";
3    
4     export default function auth(req: Request, res: Response, next: NextFunction) {
5     let token = req.body.token;
6    
7     if (!token)
8     token = req.query.token;
9    
10     if (!token || !DiscordClient.client.server.validToken(token)) {
11     res.status(401).json({
12     status: 401,
13     message: "Unauthorized",
14     detail: "Invalid authentication credentials provided"
15     });
16    
17     return;
18     }
19    
20     next();
21     };

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26