Skip to content

Commit

Permalink
fix: logout was broken after remember-me was added
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Jan 30, 2020
1 parent 0f50a76 commit 8b02471
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion komga-webui/src/plugins/komga-users.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const vuexModule: Module<any, any> = {
},
async logout ({ commit }) {
try {
await service.getMeWithAuth('', '')
await service.logout()
} catch (e) {
}
commit('setMe', {})
Expand Down
14 changes: 13 additions & 1 deletion komga-webui/src/services/komga-users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class SecurityConfiguration(
.and()
.httpBasic()

.and()
.logout()
.logoutUrl("/api/v1/users/logout")
.deleteCookies("JSESSIONID")

.and()
.sessionManagement()
.maximumSessions(10)
Expand Down

0 comments on commit 8b02471

Please sign in to comment.