-
소속부대
+
{props2.Unitname || "no data"}
-
충성, 명예, 단결
살아방패 죽어충성
+
{props2.Unitslogan || "no data"}
-
-
{props.Rank} {props.Name}
+
+ {props1.Rank} {props1.Name}
정보통신운용장교
-
- {props.DoDID}
- 정보통신운용장교
- {props.Type}
- {props.email}
+
+ {props1.DoDID || "no data"}
+ {props1.Role || "no data"}
+ {props1.Type || "no data"}
+ {props1.email || "no data"}
992-6202
010-3315-1229
-
-
-
-
- 수도방위사령부 방공여단
- 충성, 명예, 단결 살아방패 죽어충성
-
-
-
- (
-
- }
- title={{item.title}}
- description="Ant Design, a design language for background applications, is refined by Ant UED Team"
+
+
+
+
+ {props2.Unitname || "no data"}
+ {props2.Unitslogan || "no data"}
+
+
+
+ (
+
+ }
+ title={{item.title}}
+ description="Ant Design, a design language for background applications, is refined by Ant UED Team"
+ />
+
+ )}
/>
-
- )}
- />
-
-
- Content 3
-
-
-
+
+
+ Content 3
+
+
+
>
}
-const backendroot = process.env.NEXT_PUBLIC_BACKEND_ROOT
-let endpoint = backendroot + 'api/user?search='
-const secret = process.env.JWT_SECRET
+
export async function getServerSideProps(context) {
- const JWTtoken = context.req.cookies['usercookie']; // => 'value'
- console.log(JWTtoken)
- const { payload } = await jwtVerify(JWTtoken, new TextEncoder().encode(secret))
- let id = payload['id']
- console.log(id)
+ // let ciphertext = await encryptuser('test133', 'hfipoawefjapoiwfhawpoeifjwf')
+ // let decrypt = await decryptuser('test133', ciphertext)
+ // console.log(decrypt)
+ const backendroot = process.env.NEXT_PUBLIC_BACKEND_ROOT
+ const endpoint = backendroot + 'api/user/id?search='
+ const JWTtoken = context.req.cookies['usercookie'];
+ const { id } = decodeJwt(JWTtoken)
const options = {
// The method is POST because we are sending data.
method: 'GET',
@@ -126,11 +127,32 @@ export async function getServerSideProps(context) {
'Authorization': 'Bearer ' + JWTtoken
}
}
-//Fetch data from external API
- const res = await fetch(endpoint + id, options)
- const data = await res.json()
-//Pass data to the page via props
- return { props: {data} }
+ //Fetch data from external API
+ const res = await fetch(endpoint + id, options)
+ const data = await res.json()
+ //Pass data to the page via props
+ // console.log('hi')
+ // console.log(data[0]['Unit'])
+
+ if (data[0] && data[0]['Unit']) {
+ let endpoint2 = backendroot + 'api/unit/get?search='
+ const options = {
+ // The method is POST because we are sending data.
+ method: 'GET',
+ // Tell the server we're sending JSON.
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + JWTtoken
+ }
+ }
+ const res2 = await fetch(endpoint2 + data[0]['Unit'], options)
+ const data2 = await res2.json()
+ return { props: { data, data2 } }
+
+
+ }
+
+ return { props: { data } }
}
export default Home;
diff --git a/front-end/web-next/pages/index.js b/front-end/web-next/pages/index.js
index 12e53cb1..2158ab6f 100644
--- a/front-end/web-next/pages/index.js
+++ b/front-end/web-next/pages/index.js
@@ -6,13 +6,14 @@ import { Input, Form } from 'antd';
import React, { useState } from 'react';
import { setCookie } from 'cookies-next';
import { useRouter } from 'next/router';
+import { encryptuser, decryptuser } from "../encryption/userencryption"
const backendroot = process.env.NEXT_PUBLIC_BACKEND_ROOT
-
+//let val = encryptuser('a', 'b')
export default function Home() {
const router = useRouter()
const [DoDID, setDoDID] = useState();
- const [Password, setPassword] = useState();
+ const [Password, setPassword] = useState();
const [error, setError] = useState('');
let endpoint = backendroot + 'api/user/login'
let submitlogin = async (event) => {
@@ -22,23 +23,26 @@ export default function Home() {
}
const JSONdata = JSON.stringify(data)
const options = {
- // The method is POST because we are sending data.
- method: 'POST',
- // Tell the server we're sending JSON.
- headers: {
- 'Content-Type': 'application/json',
- },
- // Body of the request is the JSON data we created above.
- body: JSONdata,
+ // The method is POST because we are sending data.
+ method: 'POST',
+ // Tell the server we're sending JSON.
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ // Body of the request is the JSON data we created above.
+ body: JSONdata,
}
const response = await fetch(endpoint, options)
const result = await response.json()
- console.log(result)
if (result.token) {
setCookie('usercookie', result.token)
router.push('/home')
} else {
- setError(result.message)
+ if (result.message == '승인된 사용자이나 아직 등록되지 않았습니다. 계정 등록 후 이용해주세요.') {
+ setError('계정 등록 후 이용해주세요.')
+ } else {
+ setError(result.message)
+ }
}
}
return (
@@ -47,33 +51,33 @@ export default function Home() {
로그인
- 로그인
-
- { setDoDID(event.target.value) }} />
+ { setDoDID(event.target.value) }} />
-
- { setPassword(event.target.value) }} />
+
+ { setPassword(event.target.value) }} />
-
+
-