Skip to content

Commit

Permalink
fix: handle unauthorized error
Browse files Browse the repository at this point in the history
Fixes: #21
Signed-off-by: Grigorii Shartsev <grigorii.shartsev@nextcloud.com>
  • Loading branch information
ShGKme committed Feb 28, 2023
1 parent 231374e commit bcfa323
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ app.whenReady().then(async () => {
})

ipcMain.handle('accounts:logout', async (event) => {
await mainWindow.webContents.session.clearStorageData()
mainWindow.close()
mainWindow = createAccountsWindow()
createMainWindow = createAccountsWindow
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
if (createMainWindow === createTalkWindow) {
await mainWindow.webContents.session.clearStorageData()
mainWindow.close()
mainWindow = createAccountsWindow()
createMainWindow = createAccountsWindow
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
}
})

// On OS X it's common to re-create a window in the app when the
Expand Down
7 changes: 7 additions & 0 deletions src/stubs/nextcloud-axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ axios.interceptors.request.use((config) => {
return config
}, (error) => Promise.reject(error))

axios.interceptors.response.use((response) => response, (error) => {
if (error.response.status === 401) {
window.TALK_DESKTOP.logout()
}
return Promise.reject(error)
})

export default axios

0 comments on commit bcfa323

Please sign in to comment.