From 96039b4ab9f625a67dd7467cc6a89b7c96fbd435 Mon Sep 17 00:00:00 2001 From: tusharmakkar08 Date: Thu, 9 Apr 2020 14:26:28 +0530 Subject: [PATCH 1/2] 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') } } } From ef6154b5a1ce91bd5dc376b7beb322282cb4cce9 Mon Sep 17 00:00:00 2001 From: tusharmakkar08 Date: Sat, 11 Apr 2020 23:59:59 +0530 Subject: [PATCH 2/2] Made getter --- frontend/components/organisms/layout/TheHeader.vue | 10 ++++------ frontend/store/auth.js | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/components/organisms/layout/TheHeader.vue b/frontend/components/organisms/layout/TheHeader.vue index 8b0a39c9..271e1ebd 100644 --- a/frontend/components/organisms/layout/TheHeader.vue +++ b/frontend/components/organisms/layout/TheHeader.vue @@ -67,7 +67,7 @@ - {{ username }} + {{ getUsername }} mdi-logout @@ -84,7 +84,7 @@