New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@availity/authorize

Package Overview
Dependencies
Maintainers
9
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@availity/authorize - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

35

Authorize.js

@@ -7,4 +7,16 @@ import React, { Component } from 'react';

const watching = ['region', 'organizationId'];
const watching = ['region', 'organizationId', 'customerId'];
const warned = {};
function warnOnce(message) {
if (!warned[message]) {
// eslint-disable-next-line no-console
if (typeof console !== 'undefined' && typeof console.error === 'function') {
console.error(message); // eslint-disable-line no-console
}
warned[message] = true;
}
}
class Authorize extends Component {

@@ -28,2 +40,3 @@ static propTypes = {

organizationId: PropTypes.string,
customerId: PropTypes.string,
unauthorized: PropTypes.node,

@@ -65,12 +78,26 @@ children: PropTypes.node,

checkPermission(permission) {
const { organizationId } = this.props;
const { organizationId, customerId } = this.props;
if (!permission) return false;
if (organizationId) {
if (customerId) {
warnOnce(
'You provided both `organizationId` and `customerId` to Authorize but both cannot be used together; `organizationId` will be used and `customerId` will be ignored. If you want to use `customerId` do not provide `organizationId`.'
);
}
return (
permission.organizationIds.filter(orgId => orgId === organizationId)
.length > 0
permission.organizations.filter(
({ id: orgId }) => orgId === organizationId
).length > 0
);
}
if (customerId) {
return (
permission.organizations.filter(
({ customerId: orgCustomerId }) => orgCustomerId === customerId
).length > 0
);
}
return true;

@@ -77,0 +104,0 @@ }

@@ -6,2 +6,10 @@ # Change Log

## [1.1.7](https://github.com/Availity/availity-react/compare/@availity/authorize@1.1.6...@availity/authorize@1.1.7) (2019-06-17)
**Note:** Version bump only for package @availity/authorize
## [1.1.6](https://github.com/Availity/availity-react/compare/@availity/authorize@1.1.5...@availity/authorize@1.1.6) (2019-06-03)

@@ -8,0 +16,0 @@

4

package.json
{
"name": "@availity/authorize",
"version": "1.1.6",
"version": "1.1.7",
"author": "Evan Sharp <evan.sharp@gmail.com>",

@@ -38,3 +38,3 @@ "description": "Check user permissions to see if the current user is authorized to see your content.",

},
"gitHead": "1d6e85af650d7e0d2a133b535f6aab095a604a96"
"gitHead": "8b769202dba6a064dfce29ceb4d27580b298c666"
}

@@ -33,2 +33,3 @@ # @availity/authorize

- **`organizationId`**: String. Optional, when present, the permission will be validated to ensure it is assigned to the organization.
- **`customerId`**: String. Optional, when present, the permission will be validated to ensure it is assigned to the customer. Note: Cannot be used in combination with the `organizationId` prop
- **`region`**: String or boolean. Optional, default: `true`. When a string, the permission will be validated to ensure it is assigned in the region. When true, the current region will be used.

@@ -35,0 +36,0 @@ - **`unauthorized`**: Node. Optional. The content which will be render when the user does not have the permissions required.

@@ -18,3 +18,8 @@ import React from 'react';

id: '1234',
organizationIds: ['1111'],
organizations: [
{
id: '1111',
customerId: '1194',
},
],
},

@@ -106,2 +111,32 @@ ]);

});
test('should render authorized with correct customerId', async () => {
const { getByText } = render(
<Authorize
permissions="1234"
customerId="1194"
unauthorized="You do not have permission to see this"
>
You have permission to see this
</Authorize>
);
await waitForElement(() => getByText('You have permission to see this'));
});
test('should render unauthorized with incorrect customerId', async () => {
const { getByText } = render(
<Authorize
permissions="1234"
customerId="1193"
unauthorized="You do not have permission to see this"
>
You have permission to see this
</Authorize>
);
await waitForElement(() =>
getByText('You do not have permission to see this')
);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc