diff --git a/komga-webui/src/plugins/komga-users.plugin.ts b/komga-webui/src/plugins/komga-users.plugin.ts index 5a537eb89..300cb1cd9 100644 --- a/komga-webui/src/plugins/komga-users.plugin.ts +++ b/komga-webui/src/plugins/komga-users.plugin.ts @@ -28,7 +28,7 @@ const vuexModule: Module = { }, async logout ({ commit }) { try { - await service.getMeWithAuth('', '') + await service.logout() } catch (e) { } commit('setMe', {}) diff --git a/komga-webui/src/services/komga-users.service.ts b/komga-webui/src/services/komga-users.service.ts index af55582ad..e261a8976 100644 --- a/komga-webui/src/services/komga-users.service.ts +++ b/komga-webui/src/services/komga-users.service.ts @@ -3,7 +3,7 @@ import { AxiosInstance } from 'axios' const API_USERS = '/api/v1/users' export default class KomgaUsersService { - private http: AxiosInstance; + private http: AxiosInstance constructor (http: AxiosInstance) { this.http = http @@ -105,4 +105,16 @@ export default class KomgaUsersService { throw new Error(msg) } } + + async logout () { + try { + await this.http.post(`${API_USERS}/logout`) + } catch (e) { + let msg = `An error occurred while trying to logout` + if (e.response.data.message) { + msg += `: ${e.response.data.message}` + } + throw new Error(msg) + } + } } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/security/SecurityConfiguration.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/security/SecurityConfiguration.kt index e6767c4b5..32591887c 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/security/SecurityConfiguration.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/security/SecurityConfiguration.kt @@ -55,6 +55,11 @@ class SecurityConfiguration( .and() .httpBasic() + .and() + .logout() + .logoutUrl("/api/v1/users/logout") + .deleteCookies("JSESSIONID") + .and() .sessionManagement() .maximumSessions(10)