From 6caaa205eec3f087534422a9d6a026f6e60b7ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 5 Jun 2020 00:35:21 +0200 Subject: [PATCH 1/3] =?UTF-8?q?user=20kann=20seine=20AccessToken=20ansehen?= =?UTF-8?q?=20und=20l=C3=B6schen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/user/Config.vue | 121 ++++++++++++++++++++++++++++++- src/plugins/routes.js | 3 +- src/store/modules/jobRequests.js | 3 - src/store/modules/login.js | 2 - src/store/modules/user.js | 32 +++++++- 5 files changed, 150 insertions(+), 11 deletions(-) diff --git a/src/components/user/Config.vue b/src/components/user/Config.vue index 6d4fa8b..2cd036c 100644 --- a/src/components/user/Config.vue +++ b/src/components/user/Config.vue @@ -162,11 +162,83 @@ append-icon > +
+ Gespeicherte Sessions +
+ + + + OS: + + {{ + token.platform === 'macos' || token.platform === 'iphone' + ? apple + : token.platform === 'windows' + ? windows + : token.platfrom === 'android' + ? android + : token.platform + }} + + + {{ token.platform === 'macos' ? mac : iphone }} + + + + Browser: + + {{ + token.browser === 'chrome' + ? chrome + : token.browser === 'firefox' + ? firefox + : token.browser === 'opera' + ? opera + : token.browser === 'safari' + ? safari + : token.browser + }} + + + + Letzter Aktualisierung: {{ token.timestamp.day }}.{{ + token.timestamp.month + }}.{{ token.timestamp.year }} um + {{ + 10 > token.timestamp.hour + ? '0' + String(token.timestamp.hour) + : token.timestamp.hour + }}:{{ + 10 > token.timestamp.minute + ? '0' + String(token.timestamp.minute) + : token.timestamp.minute + }}:{{ + 10 > token.timestamp.second + ? '0' + String(token.timestamp.second) + : token.timestamp.second + }} + + Lebenszeit: {{ calcLifefime(token.lifetime) }} + + + + {{trashCan}} + + + + + + @@ -184,13 +256,34 @@ import { mdiAccount, mdiGlassCocktail, mdiCurrencyEur, - mdiFoodForkDrink + mdiFoodForkDrink, + mdiApple, + mdiGoogleChrome, + mdiFirefox, + mdiOpera, + mdiInternetExplorer, + mdiAppleSafari, + mdiLaptopMac, + mdiCellphoneIphone, + mdiTrashCan, + mdiAndroid, + mdiWindows } from '@mdi/js' import { mapGetters, mapActions } from 'vuex' export default { name: 'Config', data() { return { + apple: mdiApple, + mac: mdiLaptopMac, + iphone: mdiCellphoneIphone, + android: mdiAndroid, + mdiWindows: mdiWindows, + chrome: mdiGoogleChrome, + firefox: mdiFirefox, + opera: mdiOpera, + ie: mdiInternetExplorer, + safari: mdiAppleSafari, person: mdiAccount, bar: mdiGlassCocktail, finanzer: mdiCurrencyEur, @@ -201,6 +294,7 @@ export default { lastname: null, password: null, controlPassword: null, + trashCan: mdiTrashCan, isFulllineText: false, equal_password: value => this.password === value || 'Passwörter sind nicht identisch.', @@ -222,7 +316,9 @@ export default { methods: { ...mapActions({ saveConfig: 'user/saveConfig', - getStatus: 'user/getStatus' + getStatus: 'user/getStatus', + getTokens: 'user/getTokens', + deleteToken: 'user/deleteToken' }), getWindowWidth() { this.isFulllineText = document.documentElement.clientWidth <= 600 @@ -241,6 +337,21 @@ export default { this.saveConfig({ oldUsername: user.username, ...user }) this.password = null this.controlPassword = null + }, + calcLifefime(time) { + if (time < 60) return String(time) + 'Sekunden' + time = Math.round(time / 60) + if (time < 60) return String(time) + 'Minuten' + time = Math.round(time / 60) + if (time < 24) return String(time) + 'Stunden' + time = Math.round(time / 24) + if (time < 7) return String(time) + 'Tage' + time = Math.round(time / 7) + if (time < 30) return String(time) + 'Wochen' + time = Math.round(time / 30) + if (time < 12) return String(time) + 'Monate' + time = Math.round(time / 12) + return String(time) + 'Jahre' } }, computed: { @@ -248,7 +359,8 @@ export default { user: 'user/user', error: 'user/error', loading: 'user/loading', - status: 'user/status' + status: 'user/status', + tokens: 'user/tokens' }), lock() { return this.user.locked ? 'gesperrt' : 'nicht gesperrt' @@ -272,6 +384,7 @@ export default { }, created() { this.getStatus() + this.getTokens() } } diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 57d97c4..f0c7d92 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -72,7 +72,8 @@ const url = { storno: main + 'user/storno', getAllStatus: main + 'getAllStatus', getStatus: main + 'getStatus', - valid: main + 'valid' + valid: main + 'valid', + getAccessTokens: main + 'user/getAccessTokens' }, barU: { storno: main + 'bar/storno', diff --git a/src/store/modules/jobRequests.js b/src/store/modules/jobRequests.js index cf9af9e..92c8df1 100644 --- a/src/store/modules/jobRequests.js +++ b/src/store/modules/jobRequests.js @@ -158,13 +158,11 @@ const mutations = { : [] } }) - console.log(mop) }, setDayLoading: (state, { getters, date, value }) => { let day = getters.getDayToMe(date) day.forEach(a => { a.day.loading = value - console.log('day', value ? 'loading' : 'not loading', day, a.day.loading) }) }, deleteJobRequestFromMe: (state, jobrequest) => { @@ -240,7 +238,6 @@ const actions = { to_me.data, { headers: { Token: rootState.login.user.accessToken } } ) - console.log(to_me.data) commit('setJobRequestsToMe', to_me.data) workers_to_me.data.forEach(item => { var date = new Date( diff --git a/src/store/modules/login.js b/src/store/modules/login.js index f199244..dc45cd0 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -157,9 +157,7 @@ const actions = { }) commit('setLifeTime', response.data.value) var user = JSON.parse(localStorage.getItem('user')) - console.log('user',user) user.group = response.data.group - console.log('after',user) localStorage.setItem('user', JSON.stringify(user)) commit('updateAccessToken', user) } catch (e) { diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 7c3fce4..26d2686 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -9,7 +9,8 @@ const state = { error: '', days: [], messages: [], - status: [] + status: [], + tokens: [] } const mutations = { @@ -29,6 +30,10 @@ const mutations = { state.creditList = [] state.error = '' }, + setTokens: (state, tokens) => { + state.tokens = tokens + console.log(state.tokens) + }, createAmount(creditList) { let amount = { type: 'Schulden', @@ -317,6 +322,28 @@ const actions = { if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) } + }, + async getTokens({ commit, rootState, dispatch }) { + try { + const response = await axios.get(url.user.getAccessTokens, {headers: {Token: rootState.login.user.accessToken}}) + commit('setTokens', response.data) + dispatch('getLifeTime', null, { root: true }) + console.log('hier bin ich') + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async deleteToken({ commit, rootState, dispatch }, token) { + try { + const response = await axios.post(url.user.getAccessTokens, token,{headers: {Token: rootState.login.user.accessToken}}) + commit('setTokens', response.data) + dispatch('getLifeTime', null, { root: true }) + console.log('hier bin ich') + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } } } @@ -349,6 +376,9 @@ const getters = { }, status: state => { return state.status + }, + tokens: state => { + return state.tokens } } From 6b27441ac9f504641359a9371b42e9f8df02a0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 5 Jun 2020 01:17:21 +0200 Subject: [PATCH 2/3] =?UTF-8?q?user=20kann=20wieder=20sein=20password=20?= =?UTF-8?q?=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/user/Config.vue | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/user/Config.vue b/src/components/user/Config.vue index 2cd036c..ab89eb3 100644 --- a/src/components/user/Config.vue +++ b/src/components/user/Config.vue @@ -48,7 +48,7 @@ @@ -58,7 +58,7 @@ ref="password" v-model="controlPassword" outlined - label="Password bestätigen" + label="neues Password bestätigen" type="password" :disabled="!password" :rules="[equal_password]" @@ -242,6 +242,7 @@ + Speicherns @@ -296,6 +297,8 @@ export default { controlPassword: null, trashCan: mdiTrashCan, isFulllineText: false, + acceptedPassword: null, + passError: null, equal_password: value => this.password === value || 'Passwörter sind nicht identisch.', email: value => { @@ -304,7 +307,11 @@ export default { return pattern.test(value) || 'keine gültige E-Mail' } return true + }, + empty_password: () => { + return this.acceptedPassword !== null ? true : 'Password wurde nicht gesetzt' } + } }, mounted() { @@ -334,9 +341,14 @@ export default { if (this.$refs.password.validate()) { if (this.password) user.password = this.password } - this.saveConfig({ oldUsername: user.username, ...user }) + if (this.$refs.acceptedPassword.validate()) { + this.saveConfig({oldUsername: user.username, ...user, acceptedPassword: this.acceptedPassword}) + } else { + this.passError = "Du musst dein Password eingeben" + } this.password = null this.controlPassword = null + this.acceptedPassword = '' }, calcLifefime(time) { if (time < 60) return String(time) + 'Sekunden' From d3b980bd0238d9a2a2ace4b2bba9598e8f7ae09d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 5 Jun 2020 01:24:44 +0200 Subject: [PATCH 3/3] =?UTF-8?q?consolen=20eintr=C3=A4ge=20gel=C3=B6scht.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/user/Jobs/Day.vue | 11 +++++------ src/store/modules/user.js | 3 --- src/store/modules/userManager.js | 2 -- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/user/Jobs/Day.vue b/src/components/user/Jobs/Day.vue index 1cffde0..22d32f9 100644 --- a/src/components/user/Jobs/Day.vue +++ b/src/components/user/Jobs/Day.vue @@ -8,12 +8,12 @@ - + -
+
- + - + {{ invite.to_user.firstname }} {{ invite.to_user.lastname }} @@ -152,7 +152,7 @@ v-for="(request, index) in getRequests(day.date)" :key="index" > - + {{ request.to_user.firstname }} {{ request.to_user.lastname }} @@ -344,7 +344,6 @@ export default { return jobkinddate.job_kind }, filteredDBUsersWithJobKind() { - console.log(this.day.jobkinddate) var retVal = this.filteredDBUsers() var job_kind = this.getJob_Kind() diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 26d2686..2f1ec2d 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -32,7 +32,6 @@ const mutations = { }, setTokens: (state, tokens) => { state.tokens = tokens - console.log(state.tokens) }, createAmount(creditList) { let amount = { @@ -328,7 +327,6 @@ const actions = { const response = await axios.get(url.user.getAccessTokens, {headers: {Token: rootState.login.user.accessToken}}) commit('setTokens', response.data) dispatch('getLifeTime', null, { root: true }) - console.log('hier bin ich') } catch (e) { if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) @@ -339,7 +337,6 @@ const actions = { const response = await axios.post(url.user.getAccessTokens, token,{headers: {Token: rootState.login.user.accessToken}}) commit('setTokens', response.data) dispatch('getLifeTime', null, { root: true }) - console.log('hier bin ich') } catch (e) { if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) diff --git a/src/store/modules/userManager.js b/src/store/modules/userManager.js index 76a60a5..2ec5529 100644 --- a/src/store/modules/userManager.js +++ b/src/store/modules/userManager.js @@ -79,7 +79,6 @@ const actions = { const response = await axios.get(url.getUsers, { headers: { Token: rootState.login.user.accessToken } }) - console.log(response.data) commit('setUsers', response.data) commit('setUsersLoading', false) dispatch('getLifeTime', null, { root: true }) @@ -95,7 +94,6 @@ const actions = { const response = await axios.get(url.getUsers + '?extern=1', { headers: { Token: rootState.login.user.accessToken } }) - console.log(response.data) commit('setUsers', response.data) commit('setUsersLoading', false) dispatch('getLifeTime', null, { root: true })