Merge remote-tracking branch 'origin/iipbs/sn/dev' into iipbs/sn/ii
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
NEXT_PUBLIC_SITE_ID = SN
|
||||
NEXT_PUBLIC_PORT = 11302
|
||||
NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11302
|
||||
NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000
|
||||
NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver
|
||||
NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver #TODO 운영에서 바꿔야 함
|
||||
NEXT_PUBLIC_CLAIM_NAME = Authorization
|
||||
NEXT_PUBLIC_AUTH_USER_ID = token-id
|
||||
NEXT_PUBLIC_ACCESS_TOKEN = access-token
|
||||
NEXT_PUBLIC_REFRESH_TOKEN = refresh-token
|
||||
|
||||
NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getCookie } from "@/components/lib/utils";
|
||||
import { getCookie } from "@/shared/lib";
|
||||
import { ENDPOINT } from "../api/attachment/attachment-service";
|
||||
|
||||
const AUTH_USER_ID = process.env.NEXT_PUBLIC_AUTH_USER_ID || "token-id";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Upload, type HttpResponse } from "tus-js-client";
|
||||
import { getCookie, setCookie } from "@/components/lib/utils";
|
||||
import { getCookie, setCookie } from "@/shared/lib";
|
||||
import { ENDPOINT } from "../api/attachment/attachment-service";
|
||||
|
||||
const AUTH_USER_ID = process.env.NEXT_PUBLIC_AUTH_USER_ID || "token-id";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from "./cookie";
|
||||
export * from "./fileUploadUtil";
|
||||
export * from "./fileDownload";
|
||||
export * from './date'
|
||||
|
||||
+25
-46
@@ -1,50 +1,29 @@
|
||||
import { Button } from "@common/components";
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
"use client";
|
||||
import { LoginApi } from "@/entities/auth";
|
||||
import { useEffect } from "react";
|
||||
import { getCookie } from "@/shared/lib";
|
||||
import { AUTH_USER_ID } from "@/shared/config";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function Home() {
|
||||
redirect("/map");
|
||||
const router = useRouter();
|
||||
const userId = "admin1gmail";
|
||||
const password = "test1234!";
|
||||
const checkToken = getCookie(AUTH_USER_ID);
|
||||
|
||||
// return (
|
||||
// <div>
|
||||
// <div>
|
||||
// <h3 className="text-bold mx-4 gap-4 text-2xl">하수관망도</h3>
|
||||
// <div className="flex flex-row gap-4 p-4">
|
||||
// <Link href={"/map"}>
|
||||
// <Button>하수관망도</Button>
|
||||
// </Link>
|
||||
// </div>
|
||||
// </div>
|
||||
// <div>
|
||||
// <h3 className="text-bold mx-4 gap-4 text-2xl">운영정보 관리</h3>
|
||||
// <div className="flex flex-row gap-4 p-4">
|
||||
// <Link href={"/oper/floodPre"}>
|
||||
// <Button>도시침수 예방사업</Button>
|
||||
// </Link>
|
||||
// <Link href={"/oper/oldPp"}>
|
||||
// <Button>노후 하수관로 정비사업</Button>
|
||||
// </Link>
|
||||
// </div>
|
||||
// </div>
|
||||
// <div>
|
||||
// <h3 className="text-bold mx-4 gap-4 text-2xl">
|
||||
// I/I 분석(기초정보 설정)
|
||||
// </h3>
|
||||
// <div className="flex flex-row gap-4 p-4">
|
||||
// <Link href={"/ii/irsetting"}>
|
||||
// <Button>침입수 분석</Button>
|
||||
// </Link>
|
||||
// <Link href={"/ii/rdii"}>
|
||||
// <Button>RDII 분석</Button>
|
||||
// </Link>
|
||||
// <Link href={"/ii/result"}>
|
||||
// <Button>침입수 분석 결과</Button>
|
||||
// </Link>
|
||||
// <Link href={"/ii/rdiiResult"}>
|
||||
// <Button>RDII 분석 결과</Button>
|
||||
// </Link>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
useEffect(() => {
|
||||
if (!checkToken) {
|
||||
async function doLogin() {
|
||||
try {
|
||||
await LoginApi.login({ userId, password });
|
||||
window.location.href = "/map";
|
||||
} catch (err) {
|
||||
console.error("로그인 실패", err);
|
||||
}
|
||||
}
|
||||
doLogin();
|
||||
} else {
|
||||
router.push("/map");
|
||||
}
|
||||
}, []);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3002",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"start:sn": "next start -p 3002",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -18,7 +18,6 @@
|
||||
"@radix-ui/react-label": "^2.1.2",
|
||||
"@radix-ui/react-slot": "^1.1.2",
|
||||
"@tanstack/react-query": "^5.67.1",
|
||||
"@tanstack/react-query-devtools": "^5.75.5",
|
||||
"@tanstack/react-table": "^8.21.2",
|
||||
"axios": "^1.8.1",
|
||||
"chart.js": "^4.4.8",
|
||||
@@ -53,3 +52,6 @@
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,10 +6,8 @@ import { client } from "@/shared/api";
|
||||
import type { IUserInfo } from "@/shared/store";
|
||||
import { useUserStore } from "@/shared/lib";
|
||||
import { ENDPOINT, AUTH_USER_ID } from "@/shared/config";
|
||||
import { getCookie } from "@/components/lib/utils";
|
||||
import axios from "axios";
|
||||
import { getCookie } from "@/shared/lib";
|
||||
import { LoginApi } from "../api/login-service";
|
||||
import { tokenManager } from "../lib/token-manager";
|
||||
|
||||
const CLAIM_NAME = process.env.NEXT_PUBLIC_CLAIM_NAME || "Authorization";
|
||||
|
||||
@@ -18,32 +16,14 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
const { userInfo, setUserInfo } = useUserStore((state) => state);
|
||||
|
||||
async function authCheck() {
|
||||
const checkToken = getCookie(AUTH_USER_ID);
|
||||
|
||||
|
||||
if (!checkToken) {
|
||||
//TODO 나중에 수정해야....
|
||||
const userId = "admin1gmail";
|
||||
const password = "test1234!";
|
||||
await LoginApi.login({ userId, password });
|
||||
// window.location.href = "http://dev.onasys.co.kr/auth/login";
|
||||
// throw new Error("Missing required authentication tokens");
|
||||
const userId = getCookie(AUTH_USER_ID);
|
||||
if (!userId) {
|
||||
throw new Error("Missing required authentication tokens");
|
||||
}
|
||||
|
||||
const accessToken = tokenManager.getToken(CLAIM_NAME);
|
||||
const tokenId = tokenManager.getToken(AUTH_USER_ID);
|
||||
|
||||
const response = await axios.get<IUserInfo>(
|
||||
const response = await client.get<IUserInfo>(
|
||||
`${ENDPOINT.USER_SERVICE.USERS}/info/me`,
|
||||
{
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
[CLAIM_NAME]: accessToken,
|
||||
[AUTH_USER_ID]: tokenId ?? "",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!userInfo) setUserInfo(response.data);
|
||||
}
|
||||
|
||||
@@ -60,12 +40,7 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
} catch (refreshError) {
|
||||
console.error("Token refresh failed:", refreshError);
|
||||
setUserInfo(null);
|
||||
|
||||
// TODO 운영에 반영 할때 수정해야.....
|
||||
// 현재 경로가 로그인 페이지가 아닐 때만 redirect
|
||||
// if (!pathname.startsWith("/auth/login")) {
|
||||
// window.location.href = "http://dev.onasys.co.kr/auth/login";
|
||||
// }
|
||||
router.push("/");
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AUTH_USER_ID, CLAIM_NAME } from "@/shared/config";
|
||||
import { getCookie, setCookie, removeCookie } from "@/components/lib/utils";
|
||||
import { getCookie, setCookie, removeCookie } from "@/shared/lib";;
|
||||
|
||||
export class TokenManager {
|
||||
private static instance: TokenManager;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useEffect } from "react";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { MenuAuthorityApi } from "@/entities/menu-authority/@x/menu";
|
||||
import { useAlertStore, useMenuStore } from "@/shared/lib";
|
||||
import { getCookie } from "@/components/lib/utils";
|
||||
import { getCookie } from "@/shared/lib";;
|
||||
import { SITE_ID } from "@/shared/config";
|
||||
import { MenuApi } from "../api/menu-service";
|
||||
import { getCurrentMenu } from "./utils";
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Client } from "@common/network";
|
||||
import { BASE_URL } from "../config/api";
|
||||
import { SITE_ID } from "../config/env";
|
||||
import { setCookie } from "../lib";
|
||||
|
||||
setCookie("site-id-key", SITE_ID);
|
||||
|
||||
export const client = Client.getInstance({
|
||||
baseURL: BASE_URL,
|
||||
|
||||
@@ -3,3 +3,4 @@ export { useAlertStore } from "./use-alert-store";
|
||||
export { useMenuStore } from "./use-menu-store";
|
||||
export { useUserStore } from "./use-user-store";
|
||||
export { usePrompt } from "./use-prompt";
|
||||
export { getCookie, setCookie, removeCookie } from "./cookie";
|
||||
|
||||
Reference in New Issue
Block a user