Browse Source

companion-client: better auth state check

Ifedapo Olarewaju 5 years ago
parent
commit
edf6d687fc
1 changed files with 4 additions and 2 deletions
  1. 4 2
      packages/@uppy/companion-client/src/Provider.js

+ 4 - 2
packages/@uppy/companion-client/src/Provider.js

@@ -30,8 +30,10 @@ module.exports = class Provider extends RequestClient {
 
   onReceiveResponse (response) {
     response = super.onReceiveResponse(response)
-    const authenticated = response.status !== 401
-    this.uppy.getPlugin(this.pluginId).setPluginState({ authenticated })
+    const plugin = this.uppy.getPlugin(this.pluginId)
+    const oldAuthenticated = plugin.getPluginState().authenticated
+    const authenticated = oldAuthenticated ? response.status !== 401 : response.status < 400
+    plugin.setPluginState({ authenticated })
     return response
   }