Browse Source
Merge pull request #664 from tusharmakkar08/master
Username added at the top right corner of doccano
pull/668/head
Hiroki Nakayama
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
17 additions and
9 deletions
-
docker-compose.dev.yml
-
frontend/components/organisms/layout/TheHeader.vue
-
frontend/store/auth.js
|
|
@ -13,6 +13,7 @@ services: |
|
|
|
ADMIN_EMAIL: "admin@example.com" |
|
|
|
DATABASE_URL: "postgres://doccano:doccano@postgres:5432/doccano?sslmode=disable" |
|
|
|
ALLOW_SIGNUP: "False" |
|
|
|
DEBUG: "True" |
|
|
|
ports: |
|
|
|
- 8000:8000 |
|
|
|
depends_on: |
|
|
|
|
|
@ -59,18 +59,15 @@ |
|
|
|
</v-btn> |
|
|
|
<v-menu |
|
|
|
v-if="isAuthenticated" |
|
|
|
bottom |
|
|
|
offset-y |
|
|
|
> |
|
|
|
<template v-slot:activator="{ on }"> |
|
|
|
<v-btn |
|
|
|
v-on="on" |
|
|
|
icon |
|
|
|
> |
|
|
|
<v-btn v-on="on" on icon> |
|
|
|
<v-icon>mdi-dots-vertical</v-icon> |
|
|
|
</v-btn> |
|
|
|
</template> |
|
|
|
|
|
|
|
<v-list> |
|
|
|
<v-subheader>{{ username }}</v-subheader> |
|
|
|
<v-list-item @click="signout"> |
|
|
|
<v-list-item-icon> |
|
|
|
<v-icon>mdi-logout</v-icon> |
|
|
@ -87,7 +84,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { mapGetters, mapActions } from 'vuex' |
|
|
|
import { mapGetters, mapActions, mapState } from 'vuex' |
|
|
|
import TheColorModeSwitcher from '@/components/organisms/layout/TheColorModeSwitcher' |
|
|
|
|
|
|
|
export default { |
|
|
@ -107,7 +104,8 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
computed: { |
|
|
|
...mapGetters('auth', ['isAuthenticated']) |
|
|
|
...mapGetters('auth', ['isAuthenticated']), |
|
|
|
...mapState('auth', ['username']) |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
|
|
@ -3,7 +3,8 @@ import ApiService from '@/services/api.service' |
|
|
|
import AuthService from '@/services/auth.service' |
|
|
|
|
|
|
|
export const state = () => ({ |
|
|
|
token: null |
|
|
|
token: null, |
|
|
|
username: null |
|
|
|
}) |
|
|
|
|
|
|
|
export const mutations = { |
|
|
@ -12,6 +13,12 @@ export const mutations = { |
|
|
|
}, |
|
|
|
clearToken(state) { |
|
|
|
state.token = null |
|
|
|
}, |
|
|
|
setUsername(state, username) { |
|
|
|
state.username = username |
|
|
|
}, |
|
|
|
clearUsername(state) { |
|
|
|
state.username = null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -26,6 +33,7 @@ export const actions = { |
|
|
|
return AuthService.postCredential(authData) |
|
|
|
.then((result) => { |
|
|
|
commit('setToken', result.data.token) |
|
|
|
commit('setUsername', authData.username) |
|
|
|
localStorage.setItem('token', result.data.token) |
|
|
|
Cookie.set('jwt', result.data.token) |
|
|
|
ApiService.setHeader(result.data.token) |
|
|
@ -52,6 +60,7 @@ export const actions = { |
|
|
|
}, |
|
|
|
logout({ commit }) { |
|
|
|
commit('clearToken') |
|
|
|
commit('clearUsername') |
|
|
|
Cookie.remove('jwt') |
|
|
|
if (process.client) { |
|
|
|
localStorage.removeItem('token') |
|
|
|