fix: logout was broken after remember-me was added

This commit is contained in:
Gauthier Roebroeck 2020-01-30 11:58:39 +08:00
parent 0f50a7690f
commit 8b02471be1
3 changed files with 19 additions and 2 deletions

View file

@ -28,7 +28,7 @@ const vuexModule: Module<any, any> = {
},
async logout ({ commit }) {
try {
await service.getMeWithAuth('', '')
await service.logout()
} catch (e) {
}
commit('setMe', {})

View file

@ -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)
}
}
}

View file

@ -55,6 +55,11 @@ class SecurityConfiguration(
.and()
.httpBasic()
.and()
.logout()
.logoutUrl("/api/v1/users/logout")
.deleteCookies("JSESSIONID")
.and()
.sessionManagement()
.maximumSessions(10)