Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ORT-3_api
Browse files Browse the repository at this point in the history
  • Loading branch information
aube-dev committed Aug 30, 2024
2 parents 758b41d + a5cd638 commit 89779cb
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"git.pruneOnFetch": true
"git.pruneOnFetch": true,
"files.eol": "\n"
}
21 changes: 21 additions & 0 deletions app/components/KakaoLoginButton/KakaoLoginButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { useMemo } from 'react';
import { getUUID } from '@/utils/random';

const clientId = 'f5aa2f20e42d783654b8e8c01bfc6312';
//redirectUri는 등록된 redirectUri중에 임의로 사용했습니다.
const redirectUri = 'http://localhost:5173/oauth/kakao';

const KakaoLoginButton: React.FC = () => {
const kakaoAuthUrl = useMemo(() => {
const userUUID = getUUID();
return `https://kauth.kakao.com/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=code&state=${userUUID}`;
}, []);

return (
<a href={kakaoAuthUrl}>
<button>카카오로 로그인</button>
</a>
);
};

export default KakaoLoginButton;
3 changes: 3 additions & 0 deletions app/components/KakaoLoginButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import KakaoLoginButton from './KakaoLoginButton';

export default KakaoLoginButton;
6 changes: 4 additions & 2 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { MetaFunction } from '@remix-run/cloudflare';
import Test from '@/components/Test';
import KakaoLoginButton from '@/components/KakaoLoginButton';
// import Test from '@/components/Test';

export const meta: MetaFunction = () => [
{ title: 'ORT - 동아리 플랫폼' },
Expand All @@ -13,7 +14,8 @@ export const meta: MetaFunction = () => [
const Index = () => (
<div>
<h1>Ort</h1>
<Test />
{/* <Test /> */}
<KakaoLoginButton />
</div>
);

Expand Down
18 changes: 18 additions & 0 deletions app/routes/oauth.kakao.tsx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { LoaderFunction, json } from '@remix-run/cloudflare';

export const loader: LoaderFunction = async ({ request }) => {
const url = new URL(request.url);
const code = url.searchParams.get('code');
const state = url.searchParams.get('state');

// 이 아래의 try문 지우고 이어서 하면 됩니다
try {
console.log(code, state);
} catch {
console.log(json);
}
};

const KakaoRedirect = () => <div>카카오 로그인 중...</div>;

export default KakaoRedirect;
4 changes: 4 additions & 0 deletions app/utils/random.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { v4 as uuidv4 } from 'uuid';

//이용자의 uuid를 받아옵니다.
export const getUUID = () => uuidv4();
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"@vanilla-extract/css": "1.15.3",
"isbot": "4.4.0",
"react": "18.3.1",
"react-dom": "18.3.1"
"react-dom": "18.3.1",
"uuid": "10.0.0"
},
"devDependencies": {
"@commitlint/cli": "19.3.0",
Expand All @@ -39,6 +40,7 @@
"@storybook/test": "8.2.9",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@types/uuid": "10.0.0",
"@typescript-eslint/eslint-plugin": "7.16.0",
"@typescript-eslint/parser": "7.16.0",
"@vanilla-extract/vite-plugin": "4.0.13",
Expand Down
17 changes: 17 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 89779cb

Please sign in to comment.