

231025 서영석 사용자 쿠키 추가
@acdc615423f7bc0eb378db095c8c1c17f761e548
--- client/views/index.js
+++ client/views/index.js
... | ... | @@ -10,4 +10,7 @@ |
10 | 10 |
|
11 | 11 |
const vue = createApp(App).use(AppRouter).mount('#root'); |
12 | 12 |
|
13 |
- |
|
13 |
+if (!APP_USER_HTTP_REQUEST_URL && APP_USER_HTTP_REQUEST_URL != '/') { |
|
14 |
+ console.log('index.js APP_USER_HTTP_REQUEST_URL : ', APP_USER_HTTP_REQUEST_URL); |
|
15 |
+ AppRouter.push({ path: APP_USER_HTTP_REQUEST_URL, query: {}}) |
|
16 |
+} |
--- client/views/pages/App.vue
+++ client/views/pages/App.vue
... | ... | @@ -10,6 +10,8 @@ |
10 | 10 |
</template> |
11 | 11 |
|
12 | 12 |
<script> |
13 |
+import { useStore } from "vuex"; |
|
14 |
+import axios from "axios"; |
|
13 | 15 |
import Header from '../layout/Header.vue'; |
14 | 16 |
import Menu from '../layout/Menu.vue'; |
15 | 17 |
import Footer from '../layout/Footer.vue'; |
... | ... | @@ -17,10 +19,43 @@ |
17 | 19 |
const App = { |
18 | 20 |
data: () => { |
19 | 21 |
return { |
20 |
- } |
|
22 |
+ title: null, |
|
23 |
+ isLogin: false, |
|
24 |
+ userInfo: { |
|
25 |
+ user_id: null, |
|
26 |
+ }, |
|
27 |
+ store: useStore(), |
|
28 |
+ }; |
|
21 | 29 |
}, |
22 | 30 |
methods: { |
23 |
- |
|
31 |
+//로그인 사용자 조회 |
|
32 |
+ loginUserSelectOne: function (callback) { |
|
33 |
+ let vm = this; |
|
34 |
+ axios({ |
|
35 |
+ url: "/user/loginUserSelectOne.json", |
|
36 |
+ method: "post", |
|
37 |
+ headers: { |
|
38 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
39 |
+ }, |
|
40 |
+ }).then(function (response) { |
|
41 |
+ // console.log("getIsLogin - response : ", response); |
|
42 |
+ if (response.data.loginUser != null && response.data.loginUser['user_id'] != null) { |
|
43 |
+ vm.store.commit("setLoginUser", response.data.loginUser); |
|
44 |
+ vm.isLogin = true; |
|
45 |
+ vm.userInfo.user_id = response.data.loginUser['user_id']; |
|
46 |
+ } else { |
|
47 |
+ vm.store.commit("setLoginUser", null); |
|
48 |
+ } |
|
49 |
+ if (response.data.key != null && response.data.key['salt'] != null) { |
|
50 |
+ vm.store.commit("setKey", response.data.key); |
|
51 |
+ } else { |
|
52 |
+ vm.store.commit("setKey", null); |
|
53 |
+ } |
|
54 |
+ callback(response.data); |
|
55 |
+ }).catch(function (error) { |
|
56 |
+ console.log("getIsLogin - error : ", error); |
|
57 |
+ }); |
|
58 |
+ } |
|
24 | 59 |
}, |
25 | 60 |
watch: { |
26 | 61 |
|
... | ... | @@ -35,6 +70,47 @@ |
35 | 70 |
}, |
36 | 71 |
mounted: () => { |
37 | 72 |
console.log('Vue mounted'); |
73 |
+ this.loginUserSelectOne(); |
|
74 |
+ // //vue router에게 페이지 변경 요청을 하여, router가 페이지 변경 전, 실행되는 훅(이벤트) |
|
75 |
+ // this.$router.beforeEach((to, from, next) => { |
|
76 |
+ // const vm=this; |
|
77 |
+ // //console.log("to : ", to, ", from : ", from); |
|
78 |
+ // //로그인 사용자 조회 후, callback을 통해 로그인 사용자 정보 받기 |
|
79 |
+ // this.loginUserSelectOne(function (store) { |
|
80 |
+ // //로그인 유무(로그인 정보가 있으면 True, 없으면 False) |
|
81 |
+ // let isLogin = (store.loginUser != null && store.loginUser['user_id'] != null); |
|
82 |
+ |
|
83 |
+ // const authenticationState = store.loginUser; |
|
84 |
+ // //authorization에서는 라우터에서 메타 속성을 정의해준 값이 담겨진다. |
|
85 |
+ // // undefined, [], ["admin"], ["client"]가 올 수 있다. |
|
86 |
+ // const { authorization } = to.meta; |
|
87 |
+ // //로그인 상태 일 때 |
|
88 |
+ // if (isLogin == true) { |
|
89 |
+ // //로그인 페이지 이동은 못하게 함 |
|
90 |
+ // if (to.path == '/Login.page') { |
|
91 |
+ // next(false); |
|
92 |
+ // } else {//로그인 페이지 이 외의 페이지들을 이동 가능하게 함 |
|
93 |
+ // if (!authorization.includes(authenticationState?.user_author)) { |
|
94 |
+ // // 권한이 없는 유저는 not-found 페이지로 보낸다. |
|
95 |
+ // next({ path:"/"}); |
|
96 |
+ // } |
|
97 |
+ // next(); |
|
98 |
+ // } |
|
99 |
+ // } else {//로그인 상태가 아닐 때 |
|
100 |
+ // //로그인 페이지에서 다른 페이지로 이동하려고 할 때, 이동 못하게 함 |
|
101 |
+ // if (from.path == '/Login.page') { |
|
102 |
+ // next(false); |
|
103 |
+ // } else {//로그인 페이지 이외의 페이지에서, 페이지 이동을 하려고 할 때 |
|
104 |
+ // //로그인 페이지로 이동은 무조건 가능 |
|
105 |
+ // if (to.path == "/Login.page") { |
|
106 |
+ // next(); |
|
107 |
+ // } else {//로그인 페이지로 무조건 이동 |
|
108 |
+ // next("/Login.page"); |
|
109 |
+ // } |
|
110 |
+ // } |
|
111 |
+ // } |
|
112 |
+ // }); |
|
113 |
+ // }); |
|
38 | 114 |
} |
39 | 115 |
} |
40 | 116 |
|
+++ client/views/pages/AppStore.js
... | ... | @@ -0,0 +1,23 @@ |
1 | +import { createStore } from 'vuex'; | |
2 | + | |
3 | +export default createStore ({ | |
4 | + state: { | |
5 | + loginUser: null, | |
6 | + }, | |
7 | + getters: { | |
8 | + getLoginUser: function () { | |
9 | + | |
10 | + }, | |
11 | + getKey: function () { | |
12 | + | |
13 | + } | |
14 | + }, | |
15 | + mutations: { | |
16 | + setLoginUser: function (state, newValue) { | |
17 | + state.loginUser = newValue; | |
18 | + }, | |
19 | + setKey: function (state, newValue) { | |
20 | + state.key = newValue; | |
21 | + } | |
22 | + } | |
23 | +});(No newline at end of file) |
--- server/modules/web/Server.js
+++ server/modules/web/Server.js
... | ... | @@ -17,6 +17,11 @@ |
17 | 17 |
//Streaming 중인 자원에 새로운 데이터를 stream 공간에 추가하기 위한 라이브러리 |
18 | 18 |
const newLineStream = require('new-line'); |
19 | 19 |
|
20 |
+webServer.use((req, res, next) => { |
|
21 |
+ res.header('X-Frame-Options', 'DENY'); // or 'SAMEORIGIN' or 'ALLOW-FROM uri' |
|
22 |
+ next(); |
|
23 |
+}); |
|
24 |
+ |
|
20 | 25 |
/** |
21 | 26 |
* @author : 하석형 |
22 | 27 |
* @since : 2023.08.24 |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?