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
{ | |
"data": { | |
"roles": [ | |
{ | |
"roleId": 2, | |
"roleName": "Administrator", | |
"isActive": true, | |
"__typename": "RoleType" | |
}, | |
{ |
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
{ | |
"data": { | |
"modules": [ | |
{ | |
"idUserModule": 1, | |
"userModuleName": "Client Setup", | |
"modulePages": [ | |
{ | |
"idUserModulePage": 12, | |
"pageName": "Client Settings All Pages", |
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
{ | |
"data": { | |
"user": { | |
"firstName": "Bob", | |
"lastName": "Marley", | |
"email": "bob@yahoo.com", | |
"Pages": [ | |
{ | |
"path": "/dashboard", | |
"name": "Dashboard", |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Bootstrap Example</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> | |
<script> |
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
Array | |
( | |
[order_id] => 16 | |
[order_data] => Array | |
( | |
[total] => | |
[status] => pending | |
[currency] => ₹ | |
[user_id] => 16 | |
[payment] => cod |
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
render(){ | |
return ( | |
<div className="buttonContainer"> | |
// Button will only be displayed If Allowed Condition is True | |
{this.isActionAllowed('delete-record') && | |
<button | |
type="button" | |
className="btn btn-secondary mt-3 ml-2" | |
onClick={this.closeReceiver} |
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
isActionAllowed = (actionName = "") => { | |
return (this.props.actions.indexOf(actionName) >= 0) ? true : false; | |
} |
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 _ProtectedRoute = props => { | |
const { component: Component, path, permittedPages, stateOfuser, ...rest } = props; | |
const checkAccess = checkPageAccess(path, permittedPages); | |
//prettier-ignore | |
return <Route | |
{...rest} | |
render={props => | |
((checkAccess.isUserAuthorised == false || typeof checkAccess.isUserAuthorised == 'undefined') && stateOfuser.loginSuccess ) ? | |
(<Redirect to={{pathname: "/un-authorised"}}/>) : | |
(<Component {...props} actions={checkAccess.allowedActionsName} />) |
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 checkPageAccess = (path, permittedPages) => { | |
let isUserAuthorised = false; | |
let url = path.replace(/\//g, ""); | |
let allowedActions = []; | |
let allowedActionsName = []; | |
// If permittedPages exists | |
if( Array.isArray(permittedPages) && permittedPages.length > 0) { | |
isUserAuthorised = permittedPages.find(page => page.modulePageUrl === url); | |
permittedPages.forEach(element => { |
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 { Route } from "react-router-dom"; | |
import { Redirect } from "react-router"; | |
import { connect } from "react-redux"; | |
const checkPageAccess = (path, permittedPages) => { | |
let isUserAuthorised = false; | |
let url = path.replace(/\//g, ""); | |
let allowedActions = []; | |
let allowedActionsName = []; |