Skip to content

Commit

Permalink
fix: default tenantId is now blank
Browse files Browse the repository at this point in the history
get device should return on authenticated matching tenant
  • Loading branch information
rsdmike committed Jun 21, 2023
1 parent 1682d47 commit 61a7a5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/middleware/custom/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ exports = module.exports = function (req, res, next) {
// req.db.customProperty = req.headers['x-db-info']

// For setting the tenantId use req.tenantId
// req.tenantId = req.headers['x-tenant-id-token']
// req.tenantId = req.headers['x-tenant-id-token'] // pull tenant id from header
req.tenantId = '' // default blank tenant
// Be sure to reject requests that do not have access to the tenant
// if (req.tenantId === <resource's>.tenantId) {
// next()
Expand Down
2 changes: 1 addition & 1 deletion src/routes/devices/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function getDevice (req: Request, res: Response): Promise<void> {
try {
let tenantId = req.tenantId
const tentantIdInQuery = req.query?.tenantId
if ((tenantId == null || tenantId === '') && (tentantIdInQuery != null || tentantIdInQuery !== '')) {
if ((tenantId == null || tenantId === '') && (tentantIdInQuery != null && tentantIdInQuery !== '')) {
tenantId = tentantIdInQuery as string
}
const result = await req.db.devices.getById(req.params.guid)
Expand Down

0 comments on commit 61a7a5d

Please sign in to comment.