Skip to content

Commit

Permalink
fix: unauthorized page changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed Jan 17, 2024
1 parent 11a57b5 commit 329d887
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/entryPoints/hyperswitch/SidebarValues.res
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ let useGetSidebarValues = (~isReconEnabled: bool) => {
ApiKeyWrite,
MerchantAccountRead,
MerchantAccountWrite,
MerchantConnectorAccountRead,
// MerchantConnectorAccountRead,
ForexRead,
MerchantConnectorAccountWrite,
RoutingRead,
Expand Down
50 changes: 44 additions & 6 deletions src/utils/AccessControl.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,59 @@ let isAccessAllowed = (permission, ~permissionList) =>

module UnauthorizedPage = {
@react.component
let make = (
~message="You don't have access to this module. Contact admin for access",
~customReqMsg=`It appears that you do not currently have access to the module.`,
) => {
let make = (~message="You don't have access to this module. Contact admin for access") => {
let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext)
React.useEffect0(() => {
RescriptReactRouter.replace("/unauthorized")
None
})
<NoDataFound message renderType={Locked} />
<NoDataFound message renderType={Locked}>
<Button
text={"Go to Home"}
buttonType=Primary
onClick={_ => {
setDashboardPageState(_ => #HOME)
RescriptReactRouter.replace("/home")
}}
customButtonStyle="mt-4 !p-2"
/>
</NoDataFound>
}
}

@react.component
let make = (~isEnabled, ~acl=?, ~children) => {
let permissionList = Recoil.useRecoilValueFromAtom(HyperswitchAtom.userPermissionAtom)
// let permissionList = Recoil.useRecoilValueFromAtom(HyperswitchAtom.userPermissionAtom)
let permissionList = [
PaymentRead,
PaymentWrite,
RefundRead,
RefundWrite,
ApiKeyRead,
ApiKeyWrite,
MerchantAccountRead,
MerchantAccountWrite,
// MerchantConnectorAccountRead,
ForexRead,
MerchantConnectorAccountWrite,
RoutingRead,
RoutingWrite,
ThreeDsDecisionManagerWrite,
ThreeDsDecisionManagerRead,
SurchargeDecisionManagerWrite,
SurchargeDecisionManagerRead,
DisputeRead,
DisputeWrite,
MandateRead,
MandateWrite,
CustomerRead,
CustomerWrite,
FileRead,
FileWrite,
Analytics,
UsersRead,
UsersWrite,
]
let isAllowed = isAccessAllowed(
acl->Option.getWithDefault(UnknownPermission("")),
~permissionList,
Expand Down

0 comments on commit 329d887

Please sign in to comment.