Skip to content

Commit

Permalink
Sign out refactored app wide to prevent the listenforchanges longpoll…
Browse files Browse the repository at this point in the history
… to continue after sign out
ErikVerheul committed Feb 5, 2022
1 parent 76029c1 commit 5207494
Showing 15 changed files with 124 additions and 145 deletions.
6 changes: 1 addition & 5 deletions src/components/admin/common_admin.js
Original file line number Diff line number Diff line change
@@ -134,6 +134,7 @@ const methods = {
this.$store.state.areTeamsRemoved = false
},

// ToDo: remove this method if not used
onReset(evt) {
evt.preventDefault()
// Reset our form values
@@ -574,11 +575,6 @@ const methods = {
this.optionSelected = 'Select a task'
this.dbIsSelected = false
this.$store.state.backendMessages = []
},

signIn() {
this.$store.commit('endSession')
router.replace('/')
}
}

16 changes: 6 additions & 10 deletions src/components/auth/signin.vue
Original file line number Diff line number Diff line change
@@ -20,10 +20,7 @@
</div>
</b-form>
</div>
<div
v-if="!this.$store.state.demo"
class="text-center big-margin"
>No account yet? Ask your SM or PO to create one.</div>
<div v-if="!this.$store.state.demo" class="text-center big-margin">No account yet? Ask your SM or PO to create one.</div>
<div class="text-center">
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Licence information item in the User dropdown menu.
@@ -40,7 +37,8 @@
<b>demoUser</b>.
</p>
<p>
Note that demoUser has the overall permission of Area PO and the permissions of "PO", "developer" and "guest" for the 'Register your feature proposals and bug findings here' and 'Feel free to play with this product'.
Note that demoUser has the overall permission of Area PO and the permissions of "PO", "developer" and "guest" for the 'Register your feature proposals and bug findings here' and 'Feel free
to play with this product'.
<br />So you can do almost everything. Please do not remove other peoples entries.
</p>
</div>
@@ -51,14 +49,14 @@

<script>
export default {
data () {
data() {
return {
name: '',
password: ''
}
},
methods: {
onSubmit () {
onSubmit() {
const formData = {
name: this.name,
password: this.password
@@ -67,11 +65,9 @@ export default {
}
}
}
</script>

<style scoped>
.signin-form {
width: 400px;
margin: 30px auto;
@@ -118,7 +114,7 @@ export default {
.submit button:hover,
.submit button:active {
background-color: #408fae;
background-color: #408fae;
color: white;
}
2 changes: 1 addition & 1 deletion src/components/header/header.js
Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ const methods = {
},

onSignout() {
this.$store.dispatch('signout')
this.$store.commit('endSession', 'header - user signed out')
}
}

3 changes: 2 additions & 1 deletion src/components/header/header.vue
Original file line number Diff line number Diff line change
@@ -151,7 +151,8 @@
</b-container>
</b-modal>

<b-modal v-model="showOptionsModal" @ok="refreshPlanningboard" title="Options menu">
<!-- when not initialized do not show the options -->
<b-modal v-if="$store.state.userData.myOptions" v-model="showOptionsModal" @ok="refreshPlanningboard" title="Options menu">
<h5>For the Product details and overview</h5>
<b-form-checkbox v-model="$store.state.userData.myOptions.levelShiftWarning" value="do_warn" unchecked-value="do_not_warn">
Warn me when I move an item to another level
10 changes: 2 additions & 8 deletions src/components/initdb/initdb.vue
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
</b-form-group>
<div v-if="!$store.state.isDatabaseInitiated">
<b-button v-if="dbName" class="m-1" @click="doCreateDatabase">Create database</b-button>
<b-button class="m-1" @click="cancel" variant="outline-primary">Cancel</b-button>
<b-button class="m-1" @click="signOut" variant="outline-primary">Cancel</b-button>
</div>
<div v-else>
<h5>Success! Apart from being a CouchDb 'server admin' you have the 'admin' role.</h5>
@@ -56,7 +56,6 @@
</template>

<script>
import router from '../../router'
import AppHeader from '../header/header.vue'
export default {
@@ -108,13 +107,8 @@ export default {
this.$store.dispatch('createDatabase', payload)
},
cancel() {
this.signOut()
},
signOut() {
this.$store.commit('endSession')
router.replace('/')
this.$store.commit('endSession', 'initdb')
}
},
4 changes: 1 addition & 3 deletions src/components/mixins/generic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SEV, LEVEL, STATE, MISC } from '../../constants.js'
import router from '../../router'
import { mapGetters } from 'vuex'

const constants = {
@@ -167,8 +166,7 @@ const utilities = {
return { currentSprint, nextSprint }
} else {
alert('Error: Missing current and/or next sprint; you need to sign-in again to have the sprint calendar extended. The application will exit.')
this.$store.commit('endSession')
router.replace('/')
this.$store.commit('endSession', 'generic: getActiveSprints - Missing current and/or next sprint')
}
}
},
8 changes: 3 additions & 5 deletions src/components/serveradmin/serveradmin.vue
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@
<div v-if="$store.state.isCurrentDbChanged">
<h4>Success! Click 'Exit' to sign-out. Sign-in to see the product details view of the '{{ $store.state.selectedDatabaseName }} 'database</h4>
<div>
<b-button class="m-1" @click="signIn()">Exit</b-button>
<b-button class="m-1" @click="signOut()">Exit</b-button>
</div>
</div>
</div>
@@ -186,7 +186,6 @@
<script>
import { MISC } from '../../constants.js'
import AppHeader from '../header/header.vue'
import router from '../../router'
export default {
data() {
@@ -414,9 +413,8 @@ export default {
this.optionSelected = 'Select a task'
},
signIn() {
this.$store.commit('endSession')
router.replace('/')
signOut() {
this.$store.commit('endSession', 'serveradmin')
}
},
15 changes: 4 additions & 11 deletions src/store/modules/authentication.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SEV } from '../../constants.js'
import { localTimeAndMilis } from '../../common_functions.js'
import globalAxios from 'axios'
import router from '../../router'

// IMPORTANT: all updates on the backlogitem documents must add history in order for the changes feed to work properly (if omitted the previous event will be processed again)
// Save the history, to trigger the distribution to other online users, when all other database updates are done.

@@ -65,8 +65,7 @@ const actions = {
signin({
rootState,
state,
dispatch,
commit
dispatch
}, authData) {
function create_UUID() {
let dt = Date.now()
@@ -77,14 +76,13 @@ const actions = {
})
return uuid
}
// reset the data from the current session
if (rootState.mySessionId) commit('resetData')
globalAxios({
method: 'POST',
url: '/_session',
data: authData
}).then(res => {
rootState.online = true
rootState.signedOut = false
rootState.mySessionId = create_UUID()
state.sessionAuthData = authData
rootState.iAmAssistAdmin = res.data.roles.includes('assistAdmin')
@@ -107,17 +105,12 @@ const actions = {
{ refreshCookieLoop: null },
{ getDatabases: null }
]
dispatch('refreshCookie', { caller: 'signin', toDispatch })
dispatch('refreshCookie', { caller: 'authentication: signin', toDispatch })
}).catch(error => {
// cannot log failure here as the database name is unknown yet
// eslint-disable-next-line no-console
if (rootState.debug) console.log('Sign in failed with ' + error)
})
},

signout({commit}) {
commit('endSession')
router.replace('/')
}
}

18 changes: 6 additions & 12 deletions src/store/modules/initdb.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LEVEL, MISC } from '../../constants.js'
import { createId } from '../../common_functions.js'
import globalAxios from 'axios'
import router from '../../router'

// IMPORTANT: all updates on the backlogitem documents must add history in order for the changes feed to work properly (if omitted the previous event will be processed again)
// Save the history, to trigger the distribution to other online users, when all other database updates are done.

@@ -111,8 +111,7 @@ const actions = {
},

setDatabasePermissions({
rootState,
commit
rootState
}, payload) {
// set the persmissions on the database holding the documents
const dbPermissions = {
@@ -130,15 +129,10 @@ const actions = {
url: payload.dbName + '/_security',
data: dbPermissions
}).then(() => {
if (payload.autoSignOut) {
commit('endSession')
router.replace('/')
} else {
rootState.backendMessages.push({ seqKey: rootState.seqKey++, msg: 'setDatabasePermissions: Success, database permissions for ' + payload.dbName + ' are set' })
if (payload.reportRestoreSuccess) {
rootState.backendMessages.push({ seqKey: rootState.seqKey++, msg: 'setDatabasePermissions: Success, the database restore is ready' })
rootState.isRestoreReady = true
}
rootState.backendMessages.push({ seqKey: rootState.seqKey++, msg: 'setDatabasePermissions: Success, database permissions for ' + payload.dbName + ' are set' })
if (payload.reportRestoreSuccess) {
rootState.backendMessages.push({ seqKey: rootState.seqKey++, msg: 'setDatabasePermissions: Success, the database restore is ready' })
rootState.isRestoreReady = true
}
}).catch(error => {
rootState.backendMessages.push({ seqKey: rootState.seqKey++, msg: 'setDatabasePermissions: Failure, could not set permissions on database ' + payload.dbName + ', ' + error })
2 changes: 1 addition & 1 deletion src/store/modules/load_detail.js
Original file line number Diff line number Diff line change
@@ -251,7 +251,7 @@ const actions = {

// all products are read; initialize the helpers functions
dispatch('createHelpers')
if (!rootState.listenForChangesRunning) {
if (!rootState.signedOut && !rootState.listenForChangesRunning) {
// do not start listenForChanges again after sign-out/in
dispatch('listenForChanges')
// eslint-disable-next-line no-console
2 changes: 1 addition & 1 deletion src/store/modules/logging.js
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ const actions = {
// save the log on every watchdog cycle
dispatch('saveLog')
// if returning from a computer sleep state, restart listenForChanges
if (!rootState.listenForChangesRunning) {
if (!rootState.signedOut && !rootState.listenForChangesRunning) {
dispatch('listenForChanges')
}
}
7 changes: 3 additions & 4 deletions src/store/modules/startup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SEV } from '../../constants.js'
import { createId } from '../../common_functions.js'
import globalAxios from 'axios'

// IMPORTANT: all updates on the backlogitem documents must add history in order for the changes feed to work properly (if omitted the previous event will be processed again)
// Save the history, to trigger the distribution to other online users, when all other database updates are done.

@@ -213,8 +214,7 @@ const actions = {
if (rootGetters.isServerAdmin) { router.replace('/serveradmin') } else
if (rootGetters.isAdmin) { router.replace('/admin') } else {
alert('Error: No default product is set. Consult your administrator. The application will exit.')
commit('endSession')
router.replace('/')
commit('endSession', 'startup: getConfig - No default product is set')
}
} else {
if (configData.defaultSprintCalendar) {
@@ -265,8 +265,7 @@ const actions = {
dispatch('updateDoc', { dbName: rootState.userData.currentDb, updatedDoc: configData, toDispatch, caller: 'getConfig' })
} else {
alert('Error: No default sprint calendar is set. Consult your administrator. The application will exit.')
commit('endSession')
router.replace('/')
commit('endSession', 'startup: getConfig - No default sprint calendar is set')
}
}
}
Loading

0 comments on commit 5207494

Please sign in to comment.