Skip to content

Commit

Permalink
Merge pull request #218 from sparcs-kaist/dev
Browse files Browse the repository at this point in the history
Main branch update from Dev branch
  • Loading branch information
14KGun authored Jan 22, 2023
2 parents a55cea7 + 9fa943c commit c051d78
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
3 changes: 2 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ app.use(cookieParser());
app.use(require("response-time")(logAPIAccess));

// admin 페이지는 rate limiting을 적용하지 않습니다.
app.use("/admin/logs", require("./src/route/admin.logs"));
app.use("/admin", require("./src/route/admin"));

// Apply the rate limiting middleware to all requests
Expand All @@ -34,7 +35,7 @@ app.use(require("./src/middleware/limitRate"));
// 라우터 및 리액트
// /rooms/v2에 요청을 보내는 기존 클라이언트 코드 호환성 유지
app.use("/auth", require("./src/route/auth"));
app.use("/json/logininfo", require("./src/route/logininfo"));
app.use(["/logininfo", "/json/logininfo"], require("./src/route/logininfo"));
app.use("/users", require("./src/route/users"));
app.use(["/rooms/v2", "/rooms"], require("./src/route/rooms"));
app.use("/chats", require("./src/route/chats"));
Expand Down
12 changes: 12 additions & 0 deletions src/route/admin.logs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const express = require("express");
const path = require("path");

const router = express.Router();

// Requires admin property of the user to enter admin page.
router.use(require("../middleware/adminAuth"));

// Log 파일 제공
router.use(express.static(path.join(process.env.PWD, "logs")));

module.exports = router;
5 changes: 2 additions & 3 deletions src/route/docs/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@

```javascript
{
status: 200,
data: "logged out successfully",
ssoLogoutUrl: String, // sso 로그아웃 url
}
```

#### Errors

- 없음
- 500 / "internal server error"

### `/getToken` **(GET)**

Expand Down
11 changes: 9 additions & 2 deletions src/service/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,15 @@ const createNewTokenHandler = (req, res, userData) => {
};

const logoutHandler = (req, res) => {
logout(req, res);
res.status(200).send("logged out successfully");
try {
const { sid } = getLoginInfo(req);
const redirectUrl = security.frontUrl + "/login";
const ssoLogoutUrl = client.getLogoutUrl(sid, redirectUrl);
logout(req, res);
res.json({ ssoLogoutUrl });
} catch (e) {
res.status(500).send("Auth/logout : internal server error");
}
};

module.exports = {
Expand Down
9 changes: 7 additions & 2 deletions src/service/auth.replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ const sparcsssoHandler = (req, res) => {
};

const logoutHandler = (req, res) => {
logout(req, res);
res.status(200).send("logged out successfully");
try {
const ssoLogoutUrl = security.frontUrl + "/login";
logout(req, res);
res.json({ ssoLogoutUrl });
} catch (e) {
res.status(500).send("Auth/logout : internal server error");
}
};

module.exports = {
Expand Down
12 changes: 10 additions & 2 deletions src/service/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,20 @@ const searchByUserHandler = async (req, res) => {
.findOne({ id: req.userId })
.populate({
path: "ongoingRoom",
options: { limit: 1000 },
options: {
limit: 1000,
// ongoingRoom 은 시간 오름차순 정렬
sort: { time: 1 },
},
populate: roomPopulateOption,
})
.populate({
path: "doneRoom",
options: { limit: 1000 },
options: {
limit: 1000,
// doneRoom 은 시간 내림차순 정렬
sort: { time: -1 },
},
populate: roomPopulateOption,
})
.lean();
Expand Down

0 comments on commit c051d78

Please sign in to comment.