ifPM fix
This commit is contained in:
parent
ab313551c9
commit
7c46797634
1 changed files with 47 additions and 1 deletions
|
@ -20,7 +20,23 @@ interface API {
|
||||||
registerUser(user: NewUser): Promise<APIResponse<User>>;
|
registerUser(user: NewUser): Promise<APIResponse<User>>;
|
||||||
/** Remove a user */
|
/** Remove a user */
|
||||||
removeUser(username: string, token: string): Promise<APIResponse<User>>;
|
removeUser(username: string, token: string): Promise<APIResponse<User>>;
|
||||||
/** Login */
|
|
||||||
|
/**
|
||||||
|
* Check if user is project manager.
|
||||||
|
* @param {string} username The username of the user.
|
||||||
|
* @param {string} projectName The name of the project.
|
||||||
|
* @param {string} token The authentication token.
|
||||||
|
* @returns {Promise<APIResponse<boolean>>} A promise containing the API response indicating if the user is a project manager.
|
||||||
|
*/
|
||||||
|
checkIfProjectManager(
|
||||||
|
projectName: string,
|
||||||
|
token: string,
|
||||||
|
): Promise<APIResponse<boolean>>;
|
||||||
|
|
||||||
|
/** Logs in a user with the provided credentials.
|
||||||
|
* @param {NewUser} NewUser The user object containing username and password.
|
||||||
|
* @returns {Promise<APIResponse<string>>} A promise resolving to an API response with a token.
|
||||||
|
*/
|
||||||
login(NewUser: NewUser): Promise<APIResponse<string>>;
|
login(NewUser: NewUser): Promise<APIResponse<string>>;
|
||||||
/** Renew the token */
|
/** Renew the token */
|
||||||
renewToken(token: string): Promise<APIResponse<string>>;
|
renewToken(token: string): Promise<APIResponse<string>>;
|
||||||
|
@ -101,6 +117,36 @@ export const api: API = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async checkIfProjectManager(
|
||||||
|
projectName: string,
|
||||||
|
token: string,
|
||||||
|
): Promise<APIResponse<boolean>> {
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`/api/checkIfProjectManager?projectName=${projectName}`,
|
||||||
|
{
|
||||||
|
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: "Failed to check if project manager" };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async createProject(
|
async createProject(
|
||||||
project: NewProject,
|
project: NewProject,
|
||||||
token: string,
|
token: string,
|
||||||
|
|
Loading…
Reference in a new issue