Skip to content

Commit de8824f

Browse files
committed
feat: githublink validation in edit project (backend)
1 parent 124c299 commit de8824f

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

backend/src/main/java/com/mdgspace/activityleaderboard/controllers/ProjectController.java

+5
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ public ResponseEntity<?> updateProject(@Valid @RequestBody AddProjectRequest upd
188188
return ResponseEntity.badRequest().body("User is not the admin or manager of the org");
189189
}
190190

191+
Boolean isValidLink=githubService.isValidLink(addProjectRequest.getLink(),user.getAccesstoken());
192+
if(!isValidLink){
193+
return ResponseEntity.badRequest().body("Invalid link provided by the user");
194+
}
195+
191196
project.setName(updateProjectRequest.getName());
192197
project.setDescription(updateProjectRequest.getDescription());
193198
project.setLink(updateProjectRequest.getLink());

frontend/src/features/AddProject/index.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const AddProject = () => {
1919
const token = localStorage.getItem('token');
2020
const { spaceName } = useParams();
2121
const [orgProject, setOrgProjects] = useState<Projects | null>(null);
22-
2322
const isUnique = (name: string) => {
2423
if (orgProject && name in orgProject) {
2524
return false;
@@ -107,22 +106,20 @@ const AddProject = () => {
107106
updatedForm.description = ' ';
108107
}
109108
const res = await addProject(token, spaceName, updatedForm);
110-
// console.log(res);
111109
// TODO: Update some stuff if the link is case sensitive
112110
navigate(`/workspace/${spaceName}`);
113111
};
114112
toast.promise(func(), {
115113
loading: 'Saving Project',
116114
success: <b>Project saved</b>,
117-
error: <b>Could not save</b>,
115+
error: <b>Invalid link</b>,
118116
});
119117
} else {
120118
toast.error('Invalid inputs');
121119
}
122120
} else {
123121
toast.error('Form contains errors');
124122
}
125-
console.log('sanas');
126123
};
127124

128125
const fetchData = async () => {

frontend/src/features/AddWorkspace/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const AddWorkspace = () => {
5757
) {
5858
setForm({ ...form, members: [...form.members, form.member] });
5959
setForm({ ...form, member: '' });
60-
console.log(form);
6160
}
6261
}
6362
};

frontend/src/features/EditProject/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const EditProject = () => {
8888
toast.promise(func(), {
8989
loading: 'Saving Project',
9090
success: <b>Project saved</b>,
91-
error: <b>Could not save</b>,
91+
error: <b>Invalid link</b>,
9292
});
9393
} else {
9494
toast.error('Invalid inputs');

frontend/src/features/workspace/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ const Workspace = () => {
6767
};
6868

6969
const fetchData = async () => {
70-
console.log(userContext?.username);
7170
if (token && userContext?.username) {
7271
try {
7372
const userOrgsRes = await getUserOrgs(

0 commit comments

Comments
 (0)