Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Bug fix: Create Token button disabled #206

Merged
merged 1 commit into from
Oct 2, 2017
Merged

Bug fix: Create Token button disabled #206

merged 1 commit into from
Oct 2, 2017

Conversation

tallpauley
Copy link
Collaborator

@tallpauley tallpauley commented Oct 2, 2017

Fixes #205

Weirdly, catch() w/ no arguments doesn't resolve the promise, it rejects it. So I had a token w/out access to auth/token/create-orphan, and while the button was enabled, it was disabled again in the catch block.

This fixes the issue. @djenriquez have you experienced this behavior? Weirdly, just putting the empty anonymous function as the catch argument fixed it. I want to make sure I'm not crazy here, not a JS guru at all :)

@tallpauley tallpauley changed the title Bug fix: allow Bug fix: Create Token button disabled Oct 2, 2017
@tallpauley
Copy link
Collaborator Author

This is the policy I was using to test:

path "auth/token/create" {
  capabilities = ["update"]
}

path "sys/policy" {
  capabilities = ["read"]
}

path "sys/auth" {
  capabilities = ["read"]
}

path "sys/mounts" {
  capabilities = ["read"]
}

@djenriquez
Copy link
Owner

Interesting, I can't explain this behavior. @Lucretius thoughts?

@Lucretius
Copy link
Collaborator

So, from the Promise spec, catch just internally uses a then call with the error state of the promise returned. Without passing a function to the catch it apparently just forwards the initial error along. However, if you pass a function, even though its empty, it will swallow the thrown error and return with a resolved undefined

@tallpauley
Copy link
Collaborator Author

Thanks @Lucretius. Since the return value isn't important here, does this change look ok?

@Lucretius
Copy link
Collaborator

Yes it looks fine - the return value will be undefined but if its not being used anywhere it doesn't matter. it will sucessfully swallow the error now as you are seeing. 👍

@tallpauley tallpauley merged commit 03bc1b8 into djenriquez:master Oct 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow creating tokens from UI w/out ability to read auth/token/accessors
3 participants