Skip to content

Commit 651a3e2

Browse files
committed
Remove WARRANT_IGNORE_ID
1 parent 5f7517d commit 651a3e2

File tree

3 files changed

+3
-28
lines changed

3 files changed

+3
-28
lines changed

README.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export default MyComponent;
173173
import React from "react";
174174
import { Router, Route, Switch } from "react-router-dom";
175175
import { createBrowserHistory } from "history";
176-
import { WarrantProvider, ProtectedRoute, WARRANT_IGNORE_ID } from "@warrantdev/react-warrant-js";
176+
import { WarrantProvider, ProtectedRoute } from "@warrantdev/react-warrant-js";
177177
import PublicPage from "./PublicPage";
178178
import ProtectedPage from "./ProtectedPage";
179179

@@ -227,28 +227,6 @@ const MyComponent = () => {
227227
export default MyComponent;
228228
```
229229

230-
**NOTE:** To ignore the `objectId` when using any of the provided components, you can pass the constant `WARRANT_IGNORE_ID`. You must have a corresponding warrant that grants access to **ANY** user on the given `objectType` for this check to succeed.
231-
```jsx
232-
import React from "react";
233-
import { ProtectedComponent, WARRANT_IGNORE_ID } from "@warrantdev/react-warrant-js";
234-
235-
const MyComponent = () => {
236-
return <div>
237-
<MyPublicComponent/>
238-
{/* Only shows MyProtectedComponent if the user can "view" ANY myObject */}
239-
<ProtectedComponent
240-
objectType="myObject"
241-
objectId={WARRANT_IGNORE_ID}
242-
relation="view"
243-
>
244-
<MyProtectedComponent/>
245-
</ProtectedComponent>
246-
</div>;
247-
};
248-
249-
export default MyComponent;
250-
```
251-
252230
### `withWarrant`
253231
Use the `withWarrant` Higher Order Component (HOC) to protect components that should only be accessible to users with certain privileges.
254232

src/ProtectedRoute.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState } from "react";
22
import { Redirect, Route, RouteProps } from "react-router-dom";
3-
import { WARRANT_IGNORE_ID, WarrantCheck } from "@warrantdev/warrant-js";
3+
import { WarrantCheck } from "@warrantdev/warrant-js";
44
import useWarrant from "./useWarrant";
55

66
export interface ProtectedRouteOptions extends WarrantCheck {
@@ -32,9 +32,7 @@ const ProtectedRoute: React.FunctionComponent<ProtectedRouteProps> = ({
3232

3333
if (sessionToken) {
3434
warrants.forEach((warrant) => {
35-
if (warrant.objectId === WARRANT_IGNORE_ID) {
36-
warrant.objectId = WARRANT_IGNORE_ID;
37-
} else if (computedMatch.params[warrant.objectId]) {
35+
if (computedMatch.params[warrant.objectId]) {
3836
/** @ts-ignore */
3937
warrant.objectId = computedMatch.params[warrant.objectId];
4038
}

src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ export { default as WarrantProvider } from "./WarrantProvider";
44
export { default as useWarrant } from "./useWarrant";
55
export { default as ProtectedComponent } from "./ProtectedComponent";
66
export { default as ProtectedRoute } from "./ProtectedRoute";
7-
export { WARRANT_IGNORE_ID } from "@warrantdev/warrant-js";

0 commit comments

Comments
 (0)