Auth. guard now only renders child if authenticated.
This commit is contained in:
parent
525c2b6d5a
commit
92289c87b3
@ -23,9 +23,13 @@ export default class AuthenticationGuard extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.context.user) {
|
||||
return this.props.children;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AuthenticationGuard.defaultProps = {
|
||||
accessLevel: 0
|
||||
@ -33,4 +37,5 @@ AuthenticationGuard.defaultProps = {
|
||||
|
||||
AuthenticationGuard.propTypes = {
|
||||
accessLevel: propTypes.number,
|
||||
children: propTypes.any
|
||||
};
|
@ -11,7 +11,7 @@ export default class SportInfoCard extends React.Component {
|
||||
<Card style={{ width: "20rem" }}>
|
||||
<Card.Body>
|
||||
<Card.Title>{this.props.sport.name}</Card.Title>
|
||||
<Card.Subtitle className="mb-2 text-muted">{this.props.sport.minPlayers.toString()}</Card.Subtitle>
|
||||
<Card.Subtitle className="mb-2 text-muted">Requires a minimum of {this.props.sport.minPlayers.toString()} players.</Card.Subtitle>
|
||||
<Card.Text>
|
||||
{this.props.sport.description}
|
||||
</Card.Text>
|
||||
|
@ -41,8 +41,8 @@ export default class Dashboard extends React.Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<AuthenticationGuard>
|
||||
<div className="page-root">
|
||||
<AuthenticationGuard />
|
||||
<React.Fragment>
|
||||
<h1></h1>
|
||||
<InputGroup className="w-50">
|
||||
@ -63,10 +63,9 @@ export default class Dashboard extends React.Component {
|
||||
<h2>Available Sports</h2>
|
||||
<SportInfoCardDisplay recommendedsports={this.state.displayedSports} />
|
||||
</div>
|
||||
|
||||
|
||||
</React.Fragment>
|
||||
</div>
|
||||
</AuthenticationGuard>
|
||||
);
|
||||
}
|
||||
}
|
@ -177,9 +177,8 @@ export default class Admin extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="page-root">
|
||||
<AuthenticationGuard accessLevel={3} />
|
||||
<AuthenticationGuard accessLevel={3}>
|
||||
<React.Fragment>
|
||||
|
||||
<div className='center'>
|
||||
<h1 id='title'>Administration</h1>
|
||||
<Button onClick={() => {
|
||||
@ -207,8 +206,8 @@ export default class Admin extends React.Component {
|
||||
{/* {this.matchUserTableData()} */}
|
||||
</tbody>
|
||||
</Table>
|
||||
|
||||
</React.Fragment>
|
||||
</AuthenticationGuard >
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user