From fd89224370dcecfb9a0155ddecf9ddcf57c6dd96 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Fri, 24 May 2019 23:42:56 +0430 Subject: [PATCH] simplify logout --- lib/schemes/local.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/schemes/local.js b/lib/schemes/local.js index 164c342e3..0540fb732 100644 --- a/lib/schemes/local.js +++ b/lib/schemes/local.js @@ -109,19 +109,16 @@ export default class LocalScheme { this.$auth.setUser(user) } - async logout (endpoint) { - // Making sure that endpoint is an Object - if (!endpoint || endpoint.constructor !== Object) { - endpoint = { data: {} } - } - + async logout (endpoint = {}) { // Only connect to logout endpoint if it's configured if (this.options.endpoints.logout) { - const payloadProperties = this.options.endpoints.logout.payloadProperties - // Only add client id to payload if enabled - if (payloadProperties.clientId !== false) { - endpoint.data[payloadProperties.clientId] = this.$auth.getClientId(this.name) + const { clientId } = this.options.endpoints.logout + if (clientId) { + if (!endpoint.data) { + endpoint.data = {} + } + endpoint.data[clientId] = this.$auth.getClientId(this.name) } await this.$auth