1 line
7.8 KiB
JSON
1 line
7.8 KiB
JSON
{"remainingRequest":"/var/www/html/payroll_manager/front-end/node_modules/thread-loader/dist/cjs.js??ref--4-2!/var/www/html/payroll_manager/front-end/node_modules/ts-loader/index.js??ref--4-3!/var/www/html/payroll_manager/front-end/node_modules/tslint-loader/index.js!/var/www/html/payroll_manager/front-end/src/main/webapp/app/shared/auth/private-route.tsx","dependencies":[{"path":"/var/www/html/payroll_manager/front-end/src/main/webapp/app/shared/auth/private-route.tsx","mtime":1533613273349},{"path":"/var/www/html/payroll_manager/front-end/node_modules/react-hot-loader/webpack.js","mtime":1505850161000},{"path":"/var/www/html/payroll_manager/front-end/node_modules/cache-loader/dist/cjs.js","mtime":0},{"path":"/var/www/html/payroll_manager/front-end/node_modules/thread-loader/dist/cjs.js","mtime":0},{"path":"/var/www/html/payroll_manager/front-end/node_modules/ts-loader/index.js","mtime":1530127508000},{"path":"/var/www/html/payroll_manager/front-end/node_modules/tslint-loader/index.js","mtime":1519899048000}],"contextDependencies":[],"result":["import * as tslib_1 from \"tslib\";\nimport React from 'react';\nimport { connect } from 'react-redux';\nimport { Route, Redirect } from 'react-router-dom';\nimport ErrorBoundary from 'app/shared/error/error-boundary';\nexport var PrivateRouteComponent = function (_a) {\n var Component = _a.component, isAuthenticated = _a.isAuthenticated, isAuthorized = _a.isAuthorized, _b = _a.hasAnyAuthorities, hasAnyAuthorities = _b === void 0 ? [] : _b, rest = tslib_1.__rest(_a, [\"component\", \"isAuthenticated\", \"isAuthorized\", \"hasAnyAuthorities\"]);\n var checkAuthorities = function (props) {\n return isAuthorized ? (React.createElement(ErrorBoundary, null,\n React.createElement(Component, tslib_1.__assign({}, props)))) : (React.createElement(\"div\", { className: \"insufficient-authority\" },\n React.createElement(\"div\", { className: \"alert alert-danger\" }, \"You are not authorized to access this page.\")));\n };\n var renderRedirect = function (props) {\n return isAuthenticated ? (checkAuthorities(props)) : (React.createElement(Redirect, { to: {\n pathname: '/login',\n search: props.location.search,\n state: { from: props.location }\n } }));\n };\n if (!Component)\n throw new Error(\"A component needs to be specified for private route for path \" + rest.path);\n return React.createElement(Route, tslib_1.__assign({}, rest, { render: renderRedirect }));\n};\nexport var hasAnyAuthority = function (authorities, hasAnyAuthorities) {\n if (authorities && authorities.length !== 0) {\n if (hasAnyAuthorities.length === 0) {\n return true;\n }\n return hasAnyAuthorities.some(function (auth) { return authorities.includes(auth); });\n }\n return false;\n};\nvar mapStateToProps = function (_a, _b) {\n var _c = _a.authentication, isAuthenticated = _c.isAuthenticated, account = _c.account;\n var _d = _b.hasAnyAuthorities, hasAnyAuthorities = _d === void 0 ? [] : _d;\n return ({\n isAuthenticated: isAuthenticated,\n isAuthorized: hasAnyAuthority(account.authorities, hasAnyAuthorities)\n });\n};\n/**\n * A route wrapped in an authentication check so that routing happens only when you are authenticated.\n * Accepts same props as React router Route.\n * The route also checks for authorization if hasAnyAuthorities is specified.\n */\nexport var PrivateRoute = connect(mapStateToProps, null, null, { pure: false })(PrivateRouteComponent);\nexport default PrivateRoute;\n",{"version":3,"file":"/var/www/html/payroll_manager/front-end/src/main/webapp/app/shared/auth/private-route.tsx","sourceRoot":"","sources":["/var/www/html/payroll_manager/front-end/node_modules/tslint-loader/index.js!/var/www/html/payroll_manager/front-end/src/main/webapp/app/shared/auth/private-route.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAc,MAAM,kBAAkB,CAAC;AAG/D,OAAO,aAAa,MAAM,iCAAiC,CAAC;AAQ5D,MAAM,CAAC,IAAM,qBAAqB,GAAG,UAAC,EAMjB;IALnB,IAAA,wBAAoB,EACpB,oCAAe,EACf,8BAAY,EACZ,yBAAsB,EAAtB,2CAAsB,EACtB,gGAAO;IAEP,IAAM,gBAAgB,GAAG,UAAA,KAAK;QAC5B,OAAA,YAAY,CAAC,CAAC,CAAC,CAC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C;QAChI,eAAe,iBAAA;QACf,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC,WAAW,EAAE,iBAAiB,CAAC;KACtE,CAAC;AAH+H,CAG/H,CAAC;AAIH;;;;GAIG;AACH,MAAM,CAAC,IAAM,YAAY,GAAG,OAAO,CACjC,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC,qBAAqB,CAAC,CAAC;AAEzB,eAAe,YAAY,CAAC","sourcesContent":["import React from 'react';\nimport { connect } from 'react-redux';\nimport { Route, Redirect, RouteProps } from 'react-router-dom';\n\nimport { IRootState } from 'app/shared/reducers';\nimport ErrorBoundary from 'app/shared/error/error-boundary';\n\ninterface IOwnProps extends RouteProps {\n hasAnyAuthorities?: string[];\n}\n\nexport interface IPrivateRouteProps extends IOwnProps, StateProps {}\n\nexport const PrivateRouteComponent = ({\n component: Component,\n isAuthenticated,\n isAuthorized,\n hasAnyAuthorities = [],\n ...rest\n}: IPrivateRouteProps) => {\n const checkAuthorities = props =>\n isAuthorized ? (\n <ErrorBoundary>\n <Component {...props} />\n </ErrorBoundary>\n ) : (\n <div className=\"insufficient-authority\">\n <div className=\"alert alert-danger\">You are not authorized to access this page.</div>\n </div>\n );\n\n const renderRedirect = props =>\n isAuthenticated ? (\n checkAuthorities(props)\n ) : (\n <Redirect\n to={{\n pathname: '/login',\n search: props.location.search,\n state: { from: props.location }\n }}\n />\n );\n\n if (!Component) throw new Error(`A component needs to be specified for private route for path ${(rest as any).path}`);\n\n return <Route {...rest} render={renderRedirect} />;\n};\n\nexport const hasAnyAuthority = (authorities: string[], hasAnyAuthorities: string[]) => {\n if (authorities && authorities.length !== 0) {\n if (hasAnyAuthorities.length === 0) {\n return true;\n }\n return hasAnyAuthorities.some(auth => authorities.includes(auth));\n }\n return false;\n};\n\nconst mapStateToProps = ({ authentication: { isAuthenticated, account } }: IRootState, { hasAnyAuthorities = [] }: IOwnProps) => ({\n isAuthenticated,\n isAuthorized: hasAnyAuthority(account.authorities, hasAnyAuthorities)\n});\n\ntype StateProps = ReturnType<typeof mapStateToProps>;\n\n/**\n * A route wrapped in an authentication check so that routing happens only when you are authenticated.\n * Accepts same props as React router Route.\n * The route also checks for authorization if hasAnyAuthorities is specified.\n */\nexport const PrivateRoute = connect<StateProps, undefined, IOwnProps>(\n mapStateToProps,\n null,\n null,\n { pure: false }\n)(PrivateRouteComponent);\n\nexport default PrivateRoute;\n"]}]} |