Skip to content

Commit

Permalink
chore:
Browse files Browse the repository at this point in the history
  • Loading branch information
이은상 committed Dec 26, 2024
1 parent b6fa946 commit d479481
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion 7_auth/7_1_express_js/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import express from "express";
import { RedisController } from "./controllers/RedisController"; // Import the RedisController class
import { RedisController } from "./controllers/RedisController";
import {GithubController} from "./controllers/GitHubController"; // Import the RedisController class

const app = express();
const PORT = 3000;

// Create an instance of the RedisController
const redisController = new RedisController();
const githubController = new GithubController();

app.use(express.json());

Expand All @@ -19,6 +21,14 @@ app.post("/redis/foo", (req, res) =>
redisController.postFoo(req, res)
);

app.get("/sign-in", (req, res) =>
githubController.signIn(req, res)
)

app.get("/callback", (req, res) =>
githubController.callback(req, res)
)

// Start the Express server
app.listen(PORT, () => {
console.log(`Server is running at http://localhost:${PORT}`);
Expand Down
2 changes: 1 addition & 1 deletion 7_auth/7_1_express_js/src/controllers/GitHubController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class GithubController {
// Validate the state parameter to prevent CSRF attacks
const storedState = req.cookies['state'];
if (!storedState || storedState !== state) {
return res.status(400).send({ error: "State mismatch" });
res.status(400).send({ error: "State mismatch" });
}

try {
Expand Down

0 comments on commit d479481

Please sign in to comment.