Skip to content

Commit

Permalink
'Manage on provider' button fix (#461)
Browse files Browse the repository at this point in the history
* testing

* Update allow-marketplace-service-account-policy.yaml
  • Loading branch information
mservidio authored Feb 9, 2021
1 parent 6f3b828 commit 65eff5a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ spec:
paths:
- /v1alpha/projects/$PROJECT_ID/accounts:register
- /v1alpha/projects/$PROJECT_ID/procurements:myProducts
- operation:
methods:
- GET
paths:
- /v1alpha/projects/$PROJECT_ID/procurements:myProducts?*
39 changes: 39 additions & 0 deletions api/v1alpha/src/procurements/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,43 @@ procurements.post('/projects/:projectId/procurements:myProducts', async (req, re
}
});

/**
* @swagger
*
* /projects/{projectId}/procurements:myProducts:
* get:
* summary: Performs redirect to the Datashare My Products UI page.
* description: Returns a 301 redirect response
* tags:
* - procurements
* parameters:
* - in: path
* name: projectId
* schema:
* type: string
* required: true
* description: Project Id of the Procurement request
* responses:
* 301:
* description: Redirect to My Products URL
*/
procurements.get('/projects/:projectId/procurements:myProducts', async (req, res) => {
const projectId = req.params.projectId;
const host = commonUtil.extractHostname(req.headers.host);

const token = req.query['x-gcp-marketplace-token'];
console.log(`Dashboard called for project ${projectId}, x-gcp-marketplace-token: ${token}, body: ${JSON.stringify(req.body)}`);

const accountManager = require('../accounts/dataManager');
const data = await accountManager.register(projectId, host, token);
console.log(`Data: ${JSON.stringify(data)}`);

if (data && data.success === false) {
res.redirect(cfg.uiBaseUrl + '/myProducts');
} else {
console.log(`Writing out cookie with token: ${token} for domain: ${host}`);
res.redirect(cfg.uiBaseUrl + '/myProducts');
}
});

module.exports = procurements;

0 comments on commit 65eff5a

Please sign in to comment.