Browse Source

Added username in localstorage

pull/680/head
tusharmakkar08 4 years ago
parent
commit
96039b4ab9
2 changed files with 4 additions and 1 deletions
  1. 3
      frontend/components/organisms/layout/TheHeader.vue
  2. 2
      frontend/store/auth.js

3
frontend/components/organisms/layout/TheHeader.vue

@ -99,7 +99,8 @@ export default {
{ title: 'Sentiment Analysis', link: 'sentiment-analysis' }, { title: 'Sentiment Analysis', link: 'sentiment-analysis' },
{ title: 'Translation', link: 'translation' }, { title: 'Translation', link: 'translation' },
{ title: 'Text to SQL', link: 'text-to-sql' } { title: 'Text to SQL', link: 'text-to-sql' }
]
],
username: localStorage.getItem('username')
} }
}, },

2
frontend/store/auth.js

@ -35,6 +35,7 @@ export const actions = {
commit('setToken', result.data.token) commit('setToken', result.data.token)
commit('setUsername', authData.username) commit('setUsername', authData.username)
localStorage.setItem('token', result.data.token) localStorage.setItem('token', result.data.token)
localStorage.setItem('username', authData.username)
Cookie.set('jwt', result.data.token) Cookie.set('jwt', result.data.token)
ApiService.setHeader(result.data.token) ApiService.setHeader(result.data.token)
}) })
@ -64,6 +65,7 @@ export const actions = {
Cookie.remove('jwt') Cookie.remove('jwt')
if (process.client) { if (process.client) {
localStorage.removeItem('token') localStorage.removeItem('token')
localStorage.removeItem('username')
} }
} }
} }
Loading…
Cancel
Save