Skip to content

Commit

Permalink
(리팩토링 중) oauth 코드 재작성 시작
Browse files Browse the repository at this point in the history
  • Loading branch information
sirini committed May 9, 2024
1 parent ff226dc commit a457869
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 13 additions & 0 deletions server/database/auth/oauth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Cookie } from "elysia"
import { AUTH } from "../../../tsboard.config"

// 쿠키에 토큰 저장하기
export function saveTokenCookie(cookie: Cookie<any>, value: string, maxAge: number): void {
cookie.set({
value: cookie,
maxAge: AUTH.JWT.REFRESH_TIMEOUT * maxAge,
path: "/",
httpOnly: AUTH.COOKIE.HTTP_ONLY,
secure: AUTH.COOKIE.SECURE,
})
}
4 changes: 1 addition & 3 deletions server/routers/auth/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Elysia, t } from "elysia"
import { jwt } from "@elysiajs/jwt"
import { registerUser } from "../../database/auth/signin"
import { saveTokens } from "../../database/auth/authorization"
import { AUTH, OAUTH, TSBOARD } from "../../../tsboard.config"
import { AUTH, TSBOARD } from "../../../tsboard.config"
import { getUser } from "../../database/auth/myinfo"
import { INIT_USER } from "../../database/auth/const"
import { fail, success } from "../../util/tools"
Expand All @@ -31,8 +31,6 @@ export const oauth = new Elysia()
.get(
"/google/callback",
async ({ jwt, cookie: { refresh, oauthUserInfo }, query: { code }, set }) => {
set.headers["Content-Type"] = "text/html"

if (!process.env.OAUTH_GOOGLE_PW) {
set.redirect = TSBOARD.API.URI
return
Expand Down
2 changes: 1 addition & 1 deletion tsboard.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* TSBOARD 기본 설정 파일
*/

export const IS_DEV = false // 개발중일 때 true 로 설정 후 저장, 프로덕션에서는 false
export const IS_DEV = true // 개발중일 때 true 로 설정 후 저장, 프로덕션에서는 false
export const PORT_DEV_VITE = 3000
export const PORT_DEV = 3200
export const PORT_PROD = 3100
Expand Down

0 comments on commit a457869

Please sign in to comment.