1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

passing address to rbac component

This commit is contained in:
Jamie Hewitt 2021-05-21 14:28:11 +03:00
parent 1c6c300cf6
commit c1d6a3b036
2 changed files with 9 additions and 4 deletions

View File

@ -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<boolean>()
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.`

View File

@ -1,9 +1,12 @@
import fetch from 'cross-fetch'
import appConfig from '../../app.config'
export default async function rbacRequest(eventType: string): Promise<boolean> {
export default async function rbacRequest(
eventType: string,
address: string
): Promise<boolean> {
const url = appConfig.rbacUrl
console.log('address', address)
if (url === 'false') {
return true
} else {