Skip to content

Commit

Permalink
resetting memory credentials after disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
nnecla committed May 22, 2024
1 parent db1def4 commit dc17477
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/shared/modules/connections/connectionsDuck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ const updateAuthEnabledHelper = (
let memoryUsername = ''
let memoryPassword = ''

const resetMemoryCredentials = () => {
memoryUsername = ''
memoryPassword = ''
}

// Reducer
export default function (state = initialState, action: any) {
switch (action.type) {
Expand Down Expand Up @@ -386,8 +391,7 @@ export const useDbEpic = (action$: any, store: any) =>
export const connectEpic = (action$: any, store: any) =>
action$.ofType(CONNECT).mergeMap(async (action: any) => {
if (!action.$$responseChannel) return Rx.Observable.of(null)
memoryUsername = ''
memoryPassword = ''
resetMemoryCredentials()
bolt.closeConnection()
await new Promise<void>(resolve => setTimeout(() => resolve(), 2000))
return bolt
Expand Down Expand Up @@ -652,6 +656,7 @@ export const disconnectEpic = (action$: any, store: any) => {
.merge(action$.ofType(USER_CLEAR))
.do(() => bolt.closeConnection())
.do(() => store.dispatch(resetUseDb()))
.do(() => resetMemoryCredentials())
.do((action: any) =>
store.dispatch(updateConnection({ id: action.id, password: '' }))
)
Expand Down Expand Up @@ -912,8 +917,7 @@ export const retainCredentialsSettingsEpic = (action$: any, store: any) => {
) {
connection.username = memoryUsername
connection.password = memoryPassword
memoryUsername = ''
memoryPassword = ''
resetMemoryCredentials()
return store.dispatch(updateConnection(connection))
}
})
Expand Down

0 comments on commit dc17477

Please sign in to comment.