forked from baron/baron-sso
27 lines
742 B
TypeScript
27 lines
742 B
TypeScript
import { useEffect } from "react";
|
|
import { useAuth } from "react-oidc-context";
|
|
import { useNavigate } from "react-router-dom";
|
|
import { userManager } from "../../lib/auth";
|
|
|
|
export default function AuthCallbackPage() {
|
|
const auth = useAuth();
|
|
const navigate = useNavigate();
|
|
|
|
useEffect(() => {
|
|
// 팝업으로 열린 경우 signinPopupCallback 처리
|
|
if (window.opener) {
|
|
userManager.signinPopupCallback();
|
|
return;
|
|
}
|
|
|
|
if (auth.isAuthenticated) {
|
|
navigate("/", { replace: true });
|
|
} else if (auth.error) {
|
|
console.error("Auth Error:", auth.error);
|
|
navigate("/login", { replace: true });
|
|
}
|
|
}, [auth.isAuthenticated, auth.error, navigate]);
|
|
|
|
return <div>Loading Auth...</div>;
|
|
}
|