-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 로그인 버튼 구현 * feat: code를 추출하고 서버로 보내는 로직 구현 * feat: 로그인 버튼 클릭시 slack으로 이동하는 로직 추가 * feat: 슬랙 리다이렉션 코드 생성 기능 추가 * feat: 슬랙로그인 기능 추가
- Loading branch information
Showing
3 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useEffect } from "react"; | ||
import { useLocation, useNavigate } from "react-router-dom"; | ||
|
||
const SlackRedirectHandler = () => { | ||
const location = useLocation(); | ||
|
||
const urlParams = new URLSearchParams(); | ||
const code = urlParams.get("code"); | ||
console.log(code); | ||
useEffect(() => { | ||
const getQueryParam = (code) => { | ||
return urlParams.get("code"); | ||
}; | ||
|
||
const authorizationCode = getQueryParam("code"); | ||
|
||
if (authorizationCode) { | ||
const sendCodeToServer = async () => { | ||
try { | ||
const response = await fetch("/api/auth/login/slack", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ code: authorizationCode }), | ||
}); | ||
const data = await response.json(); | ||
console.log(data); | ||
// 로그인 성공 후 처리 (예: 토큰 저장, 메인 페이지로 리다이렉트) | ||
} catch (error) { | ||
console.error("Error:", error); | ||
// 에러 처리 (예: 에러 페이지로 리다이렉트) | ||
} | ||
}; | ||
sendCodeToServer(); | ||
} | ||
}, [location]); | ||
|
||
return <div>로그인 처리 중...</div>; | ||
}; | ||
|
||
export default SlackRedirectHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters