Browse Source

Fix handling of grant state

E.g. dropbox wasn't working because state was stored under the dynamic property.
Mikael Sand 6 years ago
parent
commit
3c2ddd32fa
1 changed files with 4 additions and 2 deletions
  1. 4 2
      packages/@uppy/companion/src/server/controllers/callback.js

+ 4 - 2
packages/@uppy/companion/src/server/controllers/callback.js

@@ -27,8 +27,10 @@ module.exports = function callback (req, res, next) {
   // add the token to cookies for thumbnail/image requests
   tokenService.addToCookies(res, uppyAuthToken, req.uppy.options)
 
-  if ((req.session.grant || {}).state) {
-    const origin = oAuthState.getFromState(req.session.grant.state, 'origin', req.uppy.options.secret)
+  const grant = (req.session.grant || {});
+  const state = grant.dynamic ? grant.dynamic.state : grant.state;
+  if (state) {
+    const origin = oAuthState.getFromState(state, 'origin', req.uppy.options.secret);
     const allowedClients = req.uppy.options.clients
     // if no preset clients then allow any client
     if (!allowedClients || hasMatch(origin, allowedClients) || hasMatch(parseUrl(origin).host, allowedClients)) {