|
1 | 1 | import { NextRequest, NextResponse } from "next/server"; |
2 | 2 | import axios from "axios"; |
3 | 3 | import { decodeJwt } from "@/middleware"; |
| 4 | +import { OauthUser } from "@/types/oauth/oauthReq"; |
| 5 | + |
4 | 6 | export const GET = async (req: NextRequest) => { |
5 | 7 | const searchParams = req.nextUrl.searchParams; |
6 | 8 | const code = searchParams.get("code"); |
@@ -41,19 +43,16 @@ export const GET = async (req: NextRequest) => { |
41 | 43 | return NextResponse.json({ message: "Invalid ID token" }, { status: 400 }); |
42 | 44 | } |
43 | 45 |
|
44 | | - const user = { |
45 | | - id: decodedIdToken.sub, |
| 46 | + const googleUser: OauthUser = { |
| 47 | + role: role || "", |
46 | 48 | name: decodedIdToken.name, |
47 | | - role: role, |
48 | | - picture: decodedIdToken.picture, |
49 | | - email: decodedIdToken.email, |
| 49 | + token: id_token, |
50 | 50 | }; |
51 | | - console.log("Google user:", user); |
52 | | - // 여기서 role이 "role":"\bowner"로 나옴 |
| 51 | + console.log("Google user:", googleUser); |
53 | 52 |
|
54 | 53 | // 사용자 정보를 클라이언트에 반환 |
55 | 54 | const response = NextResponse.redirect("http://localhost:3000"); |
56 | | - response.cookies.set("user", JSON.stringify(user), { |
| 55 | + response.cookies.set("user", JSON.stringify(googleUser), { |
57 | 56 | httpOnly: true, |
58 | 57 | secure: process.env.NODE_ENV === "production", |
59 | 58 | sameSite: "strict", |
|
0 commit comments