Skip to content

Commit 595f845

Browse files
committed
fix: ensure logout is called when loggin out
1 parent c47bfaa commit 595f845

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/main/classes/controllers/AccountController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ export class AccountController {
4040
}
4141

4242
async logout() {
43+
// Call API logout before clearing local data
44+
const account = store.store.account
45+
if (account) {
46+
try {
47+
const { NethVoiceAPI } = useNethVoiceAPI(account)
48+
await NethVoiceAPI.Authentication.logout()
49+
Log.info('AccountController.logout() - logout API call completed successfully')
50+
} catch (e) {
51+
Log.warning('Error calling logout API:', e)
52+
}
53+
}
54+
4355
store.updateStore({
4456
auth: {
4557
...store.store.auth!,

src/main/main.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,19 @@ function attachOnReadyProcess() {
355355
}
356356

357357
const account: Account = store.get('account') as Account
358-
const ext = account.data?.endpoints.extension.find((e) => e.type === "webrtc")
359358

360-
if (ext && account?.data?.default_device?.type !== 'physical') {
361-
const { NethVoiceAPI } = useNethVoiceAPI(account)
362-
const res = await NethVoiceAPI.User.default_device(ext)
363-
Log.info('Reset device', res, ext.type, ext.id)
359+
if (account?.data) {
360+
const ext = account.data.endpoints.extension.find((e) => e.type === "webrtc")
361+
362+
if (ext && account.data.default_device?.type !== 'physical') {
363+
const { NethVoiceAPI } = useNethVoiceAPI(account)
364+
const res = await NethVoiceAPI.User.default_device(ext)
365+
Log.info('Reset device', res, ext.type, ext.id)
366+
} else {
367+
Log.info('No device to reset')
368+
}
364369
} else {
365-
Log.info('No device to reset')
370+
Log.info('No account logged in, skipping device reset')
366371
}
367372

368373
// read shortcut from config and unregister

0 commit comments

Comments
 (0)