Skip to content

Commit

Permalink
refresh site call to CMS after updating site
Browse files Browse the repository at this point in the history
  • Loading branch information
ToshKoevoets committed Oct 21, 2020
1 parent 938618c commit 3a2228d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/middleware/oauth-clients.js
Expand Up @@ -62,13 +62,11 @@ exports.withAllForSite = (req, res, next) => {
return userClientApi
.fetch(authServerUrl,apiCredentials, oauthClientId)
.then((client) => {
console.log('==>> err', client);

req.siteOAuthClients.push(client);
resolve();
})
.catch((err) => {
console.log('==>> err', oauthClientId, err.message);
console.log('==>> err oauthClientId', oauthClientId, err.message);
resolve();
});
})
Expand Down
14 changes: 8 additions & 6 deletions src/routes/api/site.js
Expand Up @@ -145,32 +145,34 @@ router.route('/:siteIdOrDomain') //(\\d+)
body: JSON.stringify(Object.assign(apiCredentials, oauthClient))
}


updates.push(fetch(authUpdateUrl, options));
});

Promise.all(updates)
.then(() => {
// when succesfull return site JSON
res.json(req.site);
next()
})
.catch((e) => {
console.log('errr', e);
console.log('errr oauth', e);
next(e)
});
})
// call the site, to let the site know a refresh of the siteConfig is needed
.put(function (req, res, next) {
const site = req.results;
const cmsUrl = siteconfig.cms.url;
const cmsUrl = site.config.cms.url;

if (!cmsUrl) {
next();
}

return fetch(cmsUrl + '/modules/openstad-api/refresh')
.then(function () { next(); })
.catch(function () { next(); });
.catch(function (err) { console.log('errrr', err); next(); });
})
.put(function (req, res, next) {
// when succesfull return site JSON
res.json(req.results);
})
// delete site
// ---------
Expand Down

0 comments on commit 3a2228d

Please sign in to comment.