From 935df6016bbb6a212aabcf2d4f06a4f0e7baf9c6 Mon Sep 17 00:00:00 2001 From: Cesxhin Date: Sat, 17 Jun 2023 17:13:17 +0200 Subject: [PATCH] Fix secret --- README.md | 2 +- src/composables/useAuth.js | 4 ++-- src/nuxt.config.js | 4 ++-- src/stores/useStore.js | 26 ++++++++++++++------------ 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index d24eedb..33604e0 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,5 @@ example: NUXT_PUBLIC_WEB_BASE: "http://localhost:33333" #http://localhost:3000 [default] #--- AUTH --- - NUXT_SECRET: "secret" #animemanga [default] + NUXT_PUBLIC_SECRET: "secret" #animemanga [default] ``` \ No newline at end of file diff --git a/src/composables/useAuth.js b/src/composables/useAuth.js index 90e8867..cf867b5 100644 --- a/src/composables/useAuth.js +++ b/src/composables/useAuth.js @@ -16,7 +16,7 @@ export default function useAuth(){ }); try{ - const token = cry.AES.encrypt(JSON.stringify(data), config.secret).toString(); + const token = cry.AES.encrypt(JSON.stringify(data), config.public.secret).toString(); auth.value = token; }catch(err){ console.log(err); @@ -39,7 +39,7 @@ export default function useAuth(){ }); if(!isNil(token.value)) - return JSON.parse(cry.AES.decrypt(token.value, config.secret).toString(cry.enc.Utf8)); + return JSON.parse(cry.AES.decrypt(token.value, config.public.secret).toString(cry.enc.Utf8)); else return null; } diff --git a/src/nuxt.config.js b/src/nuxt.config.js index 39c2022..2126688 100644 --- a/src/nuxt.config.js +++ b/src/nuxt.config.js @@ -36,13 +36,13 @@ export default defineNuxtConfig({ }, runtimeConfig:{ apiBase: process.env.API_BASE || 'http://localhost:5000', - secret: 'animemanga', public: { socketBase: process.env.SOCKET_BASE || 'ws://localhost:1234/room', httpBase: process.env.HTTP_BASE || 'http://localhost:5002', basePath: process.env.BASE_PATH || '/public', - webBase: process.env.WEB_BASE || 'http://localhost:3000' + webBase: process.env.WEB_BASE || 'http://localhost:3000', + secret: 'animemanga', } }, diff --git a/src/stores/useStore.js b/src/stores/useStore.js index 32af6e7..cb202bd 100644 --- a/src/stores/useStore.js +++ b/src/stores/useStore.js @@ -35,18 +35,20 @@ export const useStore = defineStore('store', { return state.schemas; }, getSchemasBySelectSearch(state){ - const key = state.currentSelectSearch.split("-")[1]; - - for (const index in state.schemas) { - - let name = _.get(state.schemas[index], 'name'); - let type = _.get(state.schemas[index], 'type'); - if(name === key) - { - return { - nameCfg: index, - type - }; + if(!isNil(state.currentSelectSearch)){ + const key = state.currentSelectSearch.split("-")[1]; + + for (const index in state.schemas) { + + let name = _.get(state.schemas[index], 'name'); + let type = _.get(state.schemas[index], 'type'); + if(name === key) + { + return { + nameCfg: index, + type + }; + } } } return null;