(authority, error)
| 46 | */ |
| 47 | |
| 48 | const authorize = (authority, error) => { |
| 49 | /** |
| 50 | * conversion into a class |
| 51 | * 防止传入字符串时找不到staticContext造成报错 |
| 52 | * String parameters can cause staticContext not found error |
| 53 | */ |
| 54 | let classError = false; |
| 55 | |
| 56 | if (error) { |
| 57 | classError = () => error; |
| 58 | } |
| 59 | |
| 60 | if (!authority) { |
| 61 | throw new Error('authority is required'); |
| 62 | } |
| 63 | |
| 64 | return function decideAuthority(target) { |
| 65 | const component = CheckPermissions(authority, target, classError || Exception403); |
| 66 | return checkIsInstantiation(component); |
| 67 | }; |
| 68 | }; |
| 69 | |
| 70 | export default authorize; |
nothing calls this directly
no test coverage detected