Skip to content

Commit 633fdd6

Browse files
committed
구글 Oauth 로그인 기능 추가
1 parent 4aac499 commit 633fdd6

File tree

6 files changed

+47
-16
lines changed

6 files changed

+47
-16
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ Canary Lab is a technology blog where we explore the latest trends, share insigh
2222

2323
- Built with Next.js, a React-based framework for building modern web applications.
2424
- Responsive design for optimal viewing experience across devices.
25+
- OAuth login: GitHub, Google (optional).
26+
27+
## Environment Variables (OAuth)
28+
29+
- **GitHub**: `AUTH_GITHUB_ID`, `AUTH_GITHUB_SECRET`
30+
- **Google**: `AUTH_GOOGLE_ID`, `AUTH_GOOGLE_SECRET` (Google Cloud Console에서 OAuth 2.0 클라이언트 ID 생성 후 설정)

next.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ const withPWA = require("next-pwa")({
1010
const nextConfig = {
1111
images: {
1212
domains: [
13-
"*",
1413
"mazassumnida.wtf",
1514
"openweathermap.org",
1615
"avatars.githubusercontent.com",
16+
"lh3.googleusercontent.com",
17+
"lh4.googleusercontent.com",
18+
"lh5.googleusercontent.com",
19+
"lh6.googleusercontent.com",
1720
],
1821
},
1922
env: {},
Lines changed: 4 additions & 0 deletions
Loading

src/components/login/form/LoginPageForm.tsx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,34 @@ const LoginPageForm = async () => {
1313
<UserProfile user={user} />
1414
</div>
1515
) : (
16-
<form
17-
className={styles.form}
18-
// React 타입(구버전) 환경에서 server action 타입에러 회피
19-
action={
20-
(async () => {
21-
"use server";
22-
await signIn("github");
23-
}) as any
24-
}
25-
>
26-
<button className={styles.button} type="submit">
27-
<OauthLoginButton provider="github" theme="light" type="default" />
28-
</button>
29-
</form>
16+
<div className={styles.form}>
17+
<form
18+
className={styles.button_wrapper}
19+
action={
20+
(async () => {
21+
"use server";
22+
await signIn("github");
23+
}) as any
24+
}
25+
>
26+
<button className={styles.button} type="submit">
27+
<OauthLoginButton provider="github" theme="light" type="default" />
28+
</button>
29+
</form>
30+
<form
31+
className={styles.button_wrapper}
32+
action={
33+
(async () => {
34+
"use server";
35+
await signIn("google");
36+
}) as any
37+
}
38+
>
39+
<button className={styles.button} type="submit">
40+
<OauthLoginButton provider="google" theme="light" type="default" />
41+
</button>
42+
</form>
43+
</div>
3044
);
3145
};
3246

src/components/login/form/styles.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
padding: 20px;
2525
}
2626

27+
.button_wrapper {
28+
display: block;
29+
}
30+
2731
.button {
2832
all: unset;
2933
cursor: pointer;

src/components/login/oauthLoginButton/OauthLoginButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Image from "next/image";
22

33
interface IOauthLoginButton {
4-
provider: "github";
4+
provider: "github" | "google";
55
theme: "light" | "dark";
66
type: "default";
77
}

0 commit comments

Comments
 (0)