Skip to content

Commit

Permalink
magic link 로그인 성공 후 쿼리파라미터 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
jinseok1006 committed Sep 18, 2024
1 parent 9389ec2 commit e42631b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
14 changes: 11 additions & 3 deletions src/hooks/useKeycloak.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { useEffect, useState } from "react";
import { useAuth, hasAuthParams } from "react-oidc-context";
import { useNavigate } from "react-router-dom";

export default function useKeycloak() {
const auth = useAuth();
const navigate = useNavigate();
const [hasTriedSignin, setHasTriedSignin] = useState(false);

useEffect(() => {
const silentLogin = async () => {
if (hasAuthParams()) {
auth.signinSilent();
await auth.signinSilent();
navigate(location.pathname, { replace: true });
}
}, []); // TODO: 이메일 로그인 이후 state 제거 방법 생각
};

const handleLogin = async () => {
if (
Expand All @@ -24,7 +27,12 @@ export default function useKeycloak() {
setHasTriedSignin(true);
}
};

const handleLogout = () => void auth.signoutRedirect();

useEffect(() => {
silentLogin();
}, []);
const username = auth.user?.profile.preferred_username;

return {
Expand Down
16 changes: 8 additions & 8 deletions src/pages/HomePage/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ const projects = [
github: null,
docs: null,
},
// {
// title: "예약시스템",
// description: "교내 클라우드 인스턴스를 간편하게 대여할 수 있는 서비스입니다. 학생과 교직원들이 필요한 컴퓨팅 자원을 효율적으로 활용할 수 있도록 지원합니다.",
// imgSrc: "/img/booking.png",
// link: "http://114.70.193.169:18080/identity",
// github: null,
// docs: null
// },
{
title: "예약시스템",
description: "교내 클라우드 인스턴스를 간편하게 대여할 수 있는 서비스입니다. 학생과 교직원들이 필요한 컴퓨팅 자원을 효율적으로 활용할 수 있도록 지원합니다.",
imgSrc: "/img/booking.png",
link: "",
github: null,
docs: null
},
{
title: "JHelper",
description:
Expand Down

0 comments on commit e42631b

Please sign in to comment.