-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (48 loc) · 1.69 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// import dotenv from "dotenv";
// dotenv.config();
// import express from "express";
// import jwt from "jsonwebtoken";
// const app = express();
// app.use(express.json());
// let refreshTokens = [];
// app.post("/login", (req, res) => {
// const username = req.body.username;
// const password = req.body.password;
// if (username === "khoa" && password === "abcdef1") {
// const access_token = jwt.sign(
// { sub: username },
// process.env.JWT_ACCESS_SECRET,
// { expiresIn: process.env.JWT_ACCESS_TIME }
// );
// const refresh_token = generateRefreshToken(username);
// return res.json({
// status: true,
// message: "login success",
// data: { access_token, refresh_token },
// });
// }
// return res.status(401).json({ status: false, message: "login fail" });
// });
// app.post("/token", verifyRefreshToken, (req, res) => {
// const username = req.userData.sub;
// const access_token = jwt.sign(
// { sub: username },
// process.env.JWT_ACCESS_SECRET,
// { expiresIn: process.env.JWT_ACCESS_TIME }
// );
// const refresh_token = generateRefreshToken(username);
// return res.json({
// status: true,
// message: "success",
// data: { access_token, refresh_token },
// });
// });
// app.get("/dashboard", verifyToken, (req, res) => {
// return res.json({ status: true, message: "Hello from dashboard." });
// });
// app.get("/logout", verifyToken, (req, res) => {
// const username = req.userData.sub;
// refreshTokens = refreshTokens.filter((x) => x.username !== username);
// return res.json({ status: true, message: "success." });
// });
// app.listen(3000, () => console.log("server is running..."));