1.0.6 • Published 6 years ago

secure-role-component v1.0.6

Weekly downloads
31
License
-
Repository
-
Last release
6 years ago

####The module renders components based on roles.

#####Pre-requisites

Roles must be stored in the local storage with the key as roles.The values must be something like ROLE_USER,ROLE_ADMIN

#####Usage:

import React from 'react';
import  Secure from "secure-role-component"

class Dashboard extends  React.Component {
 render() {
     return (

         <Secure roles={['ROLE_USER','ROLE_ADMIN']} components={
                        <Col lg={4}>
                     <div>Hello World!</div>
                     </Col> }/>)
     }
}
Props explanantion
roles : Pass array of roles you want the user to have to view the component.
components: Pass the components you want to render conditionally.

Notes on how to use: Make an API Call to your backend and get the roles the logged in user has. Save the roles in local storage. Use the secure-role-component module as above to get conditional rendering.

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago