Created
November 28, 2018 06:57
-
-
Save minhchu/8c7eead4be6654ccc742c73c30e50d4b to your computer and use it in GitHub Desktop.
React Role Based Authorization
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 User = Authorization(['user', 'manager', 'admin']) | |
const Manager = Authorization(['manager', 'admin']) | |
const Admin = Authorization(['admin']) | |
const UserPage = User(Users) | |
const EditUserPage = Manager(EditUser) | |
const CreateUserPage = Admin(CreateUser) | |
<Router history={BrowserHistory}> | |
<Route path="/" component={App}> | |
<Route path="users" component={UserPage}> | |
<Route path=":id/edit" component={EditUserPage} /> | |
<Route path="create" component={CreateUserPage} /> | |
</Route> | |
</Route> | |
</Router> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment