From de8824fa999a0aae97251994aa30442280620b4d Mon Sep 17 00:00:00 2001 From: yash Date: Sun, 19 May 2024 18:36:17 +0530 Subject: [PATCH] feat: githublink validation in edit project (backend) --- .../activityleaderboard/controllers/ProjectController.java | 5 +++++ frontend/src/features/AddProject/index.tsx | 5 +---- frontend/src/features/AddWorkspace/index.tsx | 1 - frontend/src/features/EditProject/index.tsx | 2 +- frontend/src/features/workspace/index.tsx | 1 - 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/com/mdgspace/activityleaderboard/controllers/ProjectController.java b/backend/src/main/java/com/mdgspace/activityleaderboard/controllers/ProjectController.java index 15a786c..d44ad79 100644 --- a/backend/src/main/java/com/mdgspace/activityleaderboard/controllers/ProjectController.java +++ b/backend/src/main/java/com/mdgspace/activityleaderboard/controllers/ProjectController.java @@ -188,6 +188,11 @@ public ResponseEntity updateProject(@Valid @RequestBody AddProjectRequest upd return ResponseEntity.badRequest().body("User is not the admin or manager of the org"); } + Boolean isValidLink=githubService.isValidLink(addProjectRequest.getLink(),user.getAccesstoken()); + if(!isValidLink){ + return ResponseEntity.badRequest().body("Invalid link provided by the user"); + } + project.setName(updateProjectRequest.getName()); project.setDescription(updateProjectRequest.getDescription()); project.setLink(updateProjectRequest.getLink()); diff --git a/frontend/src/features/AddProject/index.tsx b/frontend/src/features/AddProject/index.tsx index 0f15779..2a11595 100644 --- a/frontend/src/features/AddProject/index.tsx +++ b/frontend/src/features/AddProject/index.tsx @@ -19,7 +19,6 @@ const AddProject = () => { const token = localStorage.getItem('token'); const { spaceName } = useParams(); const [orgProject, setOrgProjects] = useState(null); - const isUnique = (name: string) => { if (orgProject && name in orgProject) { return false; @@ -107,14 +106,13 @@ const AddProject = () => { updatedForm.description = ' '; } const res = await addProject(token, spaceName, updatedForm); - // console.log(res); // TODO: Update some stuff if the link is case sensitive navigate(`/workspace/${spaceName}`); }; toast.promise(func(), { loading: 'Saving Project', success: Project saved, - error: Could not save, + error: Invalid link, }); } else { toast.error('Invalid inputs'); @@ -122,7 +120,6 @@ const AddProject = () => { } else { toast.error('Form contains errors'); } - console.log('sanas'); }; const fetchData = async () => { diff --git a/frontend/src/features/AddWorkspace/index.tsx b/frontend/src/features/AddWorkspace/index.tsx index 9f2423d..89dd221 100644 --- a/frontend/src/features/AddWorkspace/index.tsx +++ b/frontend/src/features/AddWorkspace/index.tsx @@ -57,7 +57,6 @@ const AddWorkspace = () => { ) { setForm({ ...form, members: [...form.members, form.member] }); setForm({ ...form, member: '' }); - console.log(form); } } }; diff --git a/frontend/src/features/EditProject/index.tsx b/frontend/src/features/EditProject/index.tsx index 5ea2c97..59ff833 100644 --- a/frontend/src/features/EditProject/index.tsx +++ b/frontend/src/features/EditProject/index.tsx @@ -88,7 +88,7 @@ const EditProject = () => { toast.promise(func(), { loading: 'Saving Project', success: Project saved, - error: Could not save, + error: Invalid link, }); } else { toast.error('Invalid inputs'); diff --git a/frontend/src/features/workspace/index.tsx b/frontend/src/features/workspace/index.tsx index 0ea79f2..dff09ac 100644 --- a/frontend/src/features/workspace/index.tsx +++ b/frontend/src/features/workspace/index.tsx @@ -67,7 +67,6 @@ const Workspace = () => { }; const fetchData = async () => { - console.log(userContext?.username); if (token && userContext?.username) { try { const userOrgsRes = await getUserOrgs(