Skip to content

Commit

Permalink
Merge pull request #1 from jinseok1006/maintenance
Browse files Browse the repository at this point in the history
oidc 에러 핸들링 추가
  • Loading branch information
jinseok1006 authored Sep 25, 2024
2 parents a93f566 + e676a28 commit 4e0f42d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
NODE_ENV: production
VITE_KEYCLOAK_URL: https://key.jbnu.ac.kr
VITE_KEYCLOAK_REALMS: JEduTools
VITE_ADMIN_EMAIL: [email protected]

- name: Create CNAME
run: echo "jedutools.jbnu.ac.kr" > ./dist/CNAME
Expand Down
1 change: 1 addition & 0 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ function SignButton({
return <AccountButton username={username} handleLogout={handleLogout} />;
}


return (
<Button
variant="text"
Expand Down
26 changes: 18 additions & 8 deletions src/hooks/useKeycloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useEffect, useState } from "react";
import { useAuth, hasAuthParams } from "react-oidc-context";
import { useNavigate } from "react-router-dom";

const ADMIN_EMAIL = import.meta.env.VITE_ADMIN_EMAIL

export default function useKeycloak() {
const auth = useAuth();
const navigate = useNavigate();
Expand All @@ -16,15 +18,13 @@ export default function useKeycloak() {

const handleLogin = async () => {
if (
!(
auth.isAuthenticated ||
auth.activeNavigator ||
auth.isLoading ||
hasTriedSignin
)
!auth.isAuthenticated &&
!auth.activeNavigator &&
!auth.isLoading &&
!hasTriedSignin
) {
void auth.signinRedirect();
setHasTriedSignin(true);
await auth.signinRedirect();
}
};

Expand All @@ -33,8 +33,18 @@ export default function useKeycloak() {
useEffect(() => {
silentLogin();
}, []);
const username = auth.user?.profile.preferred_username;

useEffect(() => {
if (auth.error) {
alert(
`로그인에 문제가 있습니다. 관리자에게 문의 바랍니다.\n문의: ${ADMIN_EMAIL}`
);
setHasTriedSignin(false);
}
}, [auth.error, setHasTriedSignin]);


const username = auth.user?.profile.preferred_username;
return {
isAuthenticated: auth.isAuthenticated,
isLoading: auth.isLoading,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/HomePage/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Button from "@mui/material/Button";
import Container from "@mui/material/Container";
import Box from "@mui/material/Box";

const ADMIN_EMAIL = import.meta.env.VITE_ADMIN_EMAIL;

export default function Contact() {
return (
<Container sx={{ my: 5, py: 5 }}>
Expand All @@ -29,14 +31,15 @@ export default function Contact() {
startIcon={<Chat />}
href="https://open.kakao.com/o/gXXXXX" // 카카오톡 오픈채팅 링크
target="_blank"
disabled
>
카카오톡 오픈채팅방
</Button>
<Button
variant="contained"
color="secondary"
startIcon={<Email />}
href="mailto:[email protected]"
href={`mailto:${ADMIN_EMAIL}`}
>
문의 메일 보내기
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/HomePage/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const projects: Project[] = [
{
title: "JEduTools Portal",
description:
"JEudTools 서비스를 효과적으로 제공하기 위한 포털 페이지 개발 및 관리를 목표로 합니다. 본 프로젝트는 JEudTools의 다양한 기능과 서비스를 사용자 친화적인 인터페이스를 통해 접근 가능하게 만듭니다.",
"JEduTools 서비스를 효과적으로 제공하기 위한 포털 페이지 개발 및 관리를 목표로 합니다. 본 프로젝트는 JEduTools의 다양한 기능과 서비스를 사용자 친화적인 인터페이스를 통해 접근 가능하게 만듭니다.",
imgSrc: "img/portal.png",
link: "",
github: "https://github.com/JBNU-JEduTools/portal",
Expand Down

0 comments on commit 4e0f42d

Please sign in to comment.