1 |
rakin |
53 |
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 |
|
|
}; |