Skip to content

Commit

Permalink
simplify logout
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed May 24, 2019
1 parent 270f138 commit fd89224
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/schemes/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

This comment has been minimized.

Copy link
@JoaoPedroAS51

JoaoPedroAS51 May 24, 2019

Collaborator

@pi0 I added this because in my test endpoint value was "local"

This comment has been minimized.

Copy link
@pi0

pi0 May 24, 2019

Member

the first argument of login/logout is axios request config. What's the point of supporting string? And we are overriding it here anyway!

This comment has been minimized.

Copy link
@JoaoPedroAS51

JoaoPedroAS51 May 24, 2019

Collaborator

No, I meant it should be axios request config, but when I tested the endpoint value, it was a string, I don't know why

This comment has been minimized.

Copy link
@JoaoPedroAS51

JoaoPedroAS51 May 24, 2019

Collaborator

I didn't define "local"

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

This comment has been minimized.

Copy link
@JoaoPedroAS51

JoaoPedroAS51 May 24, 2019

Collaborator

@pi0 Here should be this.options.endpoints.logout.payloadProperties

if (clientId) {
if (!endpoint.data) {
endpoint.data = {}
}
endpoint.data[clientId] = this.$auth.getClientId(this.name)
}

await this.$auth
Expand Down

0 comments on commit fd89224

Please sign in to comment.