bpanel icon indicating copy to clipboard operation
bpanel copied to clipboard

Client Unauthorized Error

Open tynes opened this issue 6 years ago • 2 comments

There exists a condition in which a bug can happen here: https://github.com/bpanel-org/bpanel/blob/development/server/bcoinRouter.js#L24

If the request times out on the back end, the token is not reset For the wallet, we could do something like:

let wallet = client.wallet(id, token)
wallet.request(...)

But that wouldn't work with the node client, as it wouldn't have a wallet method. Maybe we can create a new and temporary client with something like:

// inject(Client)
let newclient = client.inject(client)
newclient.token = token
newclient.request(...)

or

// inject(Client, opts {})
let specialized = client.inject(client, { id, token })
// returns client.wallet() or client.node()
// that comes from a new client instance

Maybe inject is a static method that returns a new instance of the client? Would have to reference client.prototype to be able to reach the method then I believe

tynes avatar Aug 24 '18 01:08 tynes

That would mean making a new client on every request? Does the finally get skipped on timeouts?

bucko13 avatar Aug 24 '18 02:08 bucko13

Only if the token from the front end is different than the token on the backend, because that token needs to be proxied for some requests. I think an exception is raised and it breaks the control flow and doesn't trigger the finally

tynes avatar Aug 24 '18 05:08 tynes