From c1d6a3b03601ed68dcd908a3cfde3d3223344c57 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Fri, 21 May 2021 14:28:11 +0300 Subject: [PATCH] passing address to rbac component --- src/components/organisms/Permission.tsx | 6 ++++-- src/utils/rbac.ts | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/organisms/Permission.tsx b/src/components/organisms/Permission.tsx index 266414676..2bb03aad8 100644 --- a/src/components/organisms/Permission.tsx +++ b/src/components/organisms/Permission.tsx @@ -1,4 +1,5 @@ import React, { ReactElement, useEffect, useState } from 'react' +import { useWeb3 } from '../../providers/Web3' import rbacRequest from '../../utils/rbac' import Alert from '../atoms/Alert' @@ -10,13 +11,14 @@ export default function Permission({ children: ReactElement }): ReactElement { const [data, updateData] = useState() + const { accountId } = useWeb3() useEffect(() => { const getData = async () => { - const data = await rbacRequest(eventType) + const data = await rbacRequest(eventType, accountId) updateData(data) } getData() - }, [eventType]) + }, [eventType, accountId]) console.log('eventType', eventType) if (data === false) { const message = `Sorry, you don't have permission to ${eventType}. Please make sure you are logged in.` diff --git a/src/utils/rbac.ts b/src/utils/rbac.ts index bd1590ebb..16fb01234 100644 --- a/src/utils/rbac.ts +++ b/src/utils/rbac.ts @@ -1,9 +1,12 @@ import fetch from 'cross-fetch' import appConfig from '../../app.config' -export default async function rbacRequest(eventType: string): Promise { +export default async function rbacRequest( + eventType: string, + address: string +): Promise { const url = appConfig.rbacUrl - + console.log('address', address) if (url === 'false') { return true } else {