Sorry for the re-post - I deleted the previous post because the formatting was off, and it would not allow me to edit the question…
I have implemented Auth0 for use in our platform, and I am creating “roles” to assign to particular users. For now, I want to only create an “admin” role and assign it to users. The aim is so that I only want these particular “admins” to be able to have the ability to either view or click the “Answer” button on our forum page.
Below, is some of the code for the forum page…
return (
<div>
{/* Table of questions - with option to answer
using bootstrap 'Table' component */}
<Table striped bordered hover variant='dark' responsive>
<thead>
<tr>
<th>ID</th>
<th>Question</th>
<th>Asked by</th>
<th>Labels/Tags</th>
<th>Answer</th>
<th>Display Answers</th>
</tr>
</thead>
<tbody>
{/* within the table, take array */}
{this.state.questions.map((question) => {
return (
<tr key = {question._id}>
<td>{question._id}</td>
<td>{question.questionText}</td>
<td>{question.username}</td>
<td>{question.labels}</td>
<td><Button onClick={() => this.handleClickPostAnswer(question._id, question.questionText)}>Answer</Button></td>
<td><Button onClick={() => this.handleClickReadAnswers(question._id)}>Display</Button></td>
</tr>
);
})}
</tbody>
{/* renders AnswersModal if this.state.displayAnswers is true */}
<AnswersModal show={this.state.displayAnswers}/>
</Table>
</div>
);
Below is the line of code that creates the Answer button. I only want this visible or be able to be clicked on for admins which I will assign as roles in Auth0.
<td><Button onClick={() => this.handleClickPostAnswer(question._id, question.questionText)}>Answer</Button></td>
Is anyone able to suggest the best way of doing this, or point me towards a resource that could help with this? Do I need to perhaps instead of roles, create rules on Auth0?
Thanks!