From 96039b4ab9f625a67dd7467cc6a89b7c96fbd435 Mon Sep 17 00:00:00 2001 From: tusharmakkar08 Date: Thu, 9 Apr 2020 14:26:28 +0530 Subject: [PATCH] Added username in localstorage --- frontend/components/organisms/layout/TheHeader.vue | 3 ++- frontend/store/auth.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/components/organisms/layout/TheHeader.vue b/frontend/components/organisms/layout/TheHeader.vue index 2aaf87fd..8b0a39c9 100644 --- a/frontend/components/organisms/layout/TheHeader.vue +++ b/frontend/components/organisms/layout/TheHeader.vue @@ -99,7 +99,8 @@ export default { { title: 'Sentiment Analysis', link: 'sentiment-analysis' }, { title: 'Translation', link: 'translation' }, { title: 'Text to SQL', link: 'text-to-sql' } - ] + ], + username: localStorage.getItem('username') } }, diff --git a/frontend/store/auth.js b/frontend/store/auth.js index b5371fd4..c98582cf 100644 --- a/frontend/store/auth.js +++ b/frontend/store/auth.js @@ -35,6 +35,7 @@ export const actions = { commit('setToken', result.data.token) commit('setUsername', authData.username) localStorage.setItem('token', result.data.token) + localStorage.setItem('username', authData.username) Cookie.set('jwt', result.data.token) ApiService.setHeader(result.data.token) }) @@ -64,6 +65,7 @@ export const actions = { Cookie.remove('jwt') if (process.client) { localStorage.removeItem('token') + localStorage.removeItem('username') } } }