Last active
January 14, 2016 08:19
-
-
Save iswanj/029c2a09bd4431a8bc54 to your computer and use it in GitHub Desktop.
Handling Permissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isPremited = (roles, type) => { | |
// premission check logic | |
return ...; | |
} | |
export { isPremited }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { isPremited } from './premission'; // custom module | |
class UserList extends React.Component { | |
renderEdit() { | |
let { roles } = this.props; | |
if(!isPremited(roles, 'EDIT_USER')) return null; | |
return ( | |
<Button>Edit</Button> | |
); | |
} | |
render() { | |
let editButton = () => { this.renderEdit(); } | |
return( | |
<div> | |
<User /> | |
{editButton} | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment