Added checkIfProjectManager, hope it works
This commit is contained in:
		
							parent
							
								
									382ea38558
								
							
						
					
					
						commit
						e48bf5d98c
					
				
					 1 changed files with 30 additions and 0 deletions
				
			
		|  | @ -20,6 +20,12 @@ interface API { | |||
|   registerUser(user: NewUser): Promise<APIResponse<User>>; | ||||
|   /** Remove a user */ | ||||
|   removeUser(username: string, token: string): Promise<APIResponse<User>>; | ||||
|   /** Check if user is project manager */ | ||||
|   checkIfProjectManager( | ||||
|     username: string, | ||||
|     projectName: string, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<boolean>>; | ||||
|   /** Login */ | ||||
|   login(NewUser: NewUser): Promise<APIResponse<string>>; | ||||
|   /** Renew the token */ | ||||
|  | @ -106,6 +112,30 @@ export const api: API = { | |||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   async checkIfProjectManager(token: string): Promise<APIResponse<boolean>> { | ||||
|     try { | ||||
|       const response = await fetch("/api/checkIfProjectManager", { | ||||
|         method: "GET", | ||||
|         headers: { | ||||
|           "Content-Type": "application/json", | ||||
|           Authorization: "Bearer " + token, | ||||
|         }, | ||||
|       }); | ||||
| 
 | ||||
|       if (!response.ok) { | ||||
|         return { | ||||
|           success: false, | ||||
|           message: "Failed to check if project manager", | ||||
|         }; | ||||
|       } else { | ||||
|         const data = (await response.json()) as boolean; | ||||
|         return { success: true, data }; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return { success: false, message: "fuck" }; | ||||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   async createProject( | ||||
|     project: NewProject, | ||||
|     token: string, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 al8763be
						al8763be