mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-31 10:49:00 +00:00 
			
		
		
		
	 f0e970b465
			
		
	
	
		f0e970b465
		
	
	
	
	
		
			
			* finish the alc access page layout, logics and sass files * Fix css issue and request permission response error message * finish the testing part * simplify code finished * finish spinner * Finished ACL access page, testing cases, clean code format * Clean format, address comments, refactor JS code of ACL page to TS * address comments, replace type any and fix merge issue
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { getJSON, postJSON } from 'wherehows-web/utils/api/fetcher';
 | |
| import { IPrincipal, IRequestResponse } from 'wherehows-web/typings/api/datasets/aclaccess';
 | |
| 
 | |
| /**
 | |
|  * Defined ACL authentication server address
 | |
|  */
 | |
| const queryAccessUrl = '/api/v1/acl';
 | |
| 
 | |
| /**
 | |
|  * Defined ACL authentication server URL
 | |
|  * @param {string} userName 
 | |
|  * @return {string} aclAuthURL
 | |
|  */
 | |
| const aclAuthURL = (userName: string): string => `${queryAccessUrl}?LDAP=${userName}`;
 | |
| 
 | |
| /**
 | |
|  *  Defined the method to check a user ACL authorization status
 | |
|  * @param {string} userName 
 | |
|  * @return {Promise<any>} checkAclAccess
 | |
|  */
 | |
| const checkAclAccess = async (userName: string): Promise<any> => {
 | |
|   return await getJSON({ url: aclAuthURL(userName) });
 | |
| };
 | |
| 
 | |
| /**
 | |
|  *  Defined the method to request ACL page permission
 | |
|  * @param {string} userName
 | |
|  * @param {IPrincipal} data 
 | |
|  * @return {Promise<IRequestResponse>} getAclAccess
 | |
|  */
 | |
| const getAclAccess = (userName: string, data: IPrincipal): Promise<IRequestResponse> => {
 | |
|   return postJSON({
 | |
|     url: aclAuthURL(userName),
 | |
|     data
 | |
|   });
 | |
| };
 | |
| 
 | |
| export { checkAclAccess, getAclAccess };
 |