diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java index b5d2c99..621a470 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -53,9 +53,9 @@ public class MockController { User joe = new User("Mama","Joe","student@student.com","roundabout","DaWarudo",new Date(0), null,Role.Student,passwordEncoder.encode("student")); User meh = new User("Inspiration","lackOf","secretary@secretary.com","a Box","the street",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary")); User joke = new User("CthemBalls","Lemme","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); - User joke = new User("hhoo","yeay","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); + User jojo = new User("hhoo","yeay","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService")); - mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena)); + mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo)); userRepo.saveAll(mockUsers); diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java index 2845185..20ca9ee 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java @@ -125,7 +125,7 @@ public class UserController { @DeleteMapping("/user/{id}") public ResponseEntity deleteStudent(@RequestHeader("Authorization") String token, @PathVariable Long id){ - if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token) || id.equals(authServ.getUserFromToken(token).getRegNo())) + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token) && !id.equals(authServ.getUserFromToken(token).getRegNo())) return new UnauthorizedResponse<>(null); User toDelete = userService.getUserById(id); diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index f59ff09..b43b152 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -36,7 +36,6 @@ }, "500"); } function verifyInputs(pass){ - console.log(pass) if(pass==passwordConfirm.value){ page.value++; return toast('Password and Confirm Password are correct.', { @@ -141,7 +140,7 @@
-
diff --git a/frontend/src/Apps/ManageCourses.vue b/frontend/src/Apps/ManageCourses.vue index d03d076..475057c 100644 --- a/frontend/src/Apps/ManageCourses.vue +++ b/frontend/src/Apps/ManageCourses.vue @@ -10,8 +10,6 @@ const curriculum = ref(await getCourses(self.role)); const profList = await getTeachers(); - console.log(curriculum) - console.log(profList) const createMod = ref(false) const deleteMod = ref(false) diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index 093e2cc..3e2eacc 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -6,19 +6,15 @@ import i18n from "@/i18n.js" import { uploadProfilePicture } from '@/rest/uploads.js' - const user = await getSelf(); - console.log(user); + const user = ref(await getSelf()); const UserCurriculum = ref(""); const curricula = ref (await getAllCurriculums()); - console.log(curricula) - console.log(user.role === "Teacher") - if(user.role === "Student"){ + if(user.value.role === "Student"){ UserCurriculum.value = await getSelfCurriculum(); } if(user.role === "Teacher"){ UserCurriculum.value = await getCourses("Teacher"); - console.log(UserCurriculum.value) } const modif = ref(false); const curric = ref(false); @@ -27,7 +23,7 @@ const pattern = { profilPictureUrl:null, email:null, - adress:null, + address:null, password:null, }; @@ -46,17 +42,38 @@ inputs=Object.assign({},list); } - function ChangeInfos(){ - for (const [key, value] in Object.entries(toModify)){ - if(value !== null){ - alterSelf({key:value}); - } + async function ChangeInfos(){ + for (let element in toModify){ + if (element =="email" && (toModify[element] !== null)){ + await alterSelf(user.value.regNo,{email : toModify[element]}); + } + + if (element =="profilPictureUrl" && (toModify[element] !== null)){ + await alterSelf(user.value.regNo,{ profilPictureUrl : toModify[element]}); + } + else if(element == "address" && (toModify[element] !== null)){ + await alterSelf(user.value.regNo,{address : toModify[element]}); + } + else if(element == "password" && (toModify[element] !== null)){ + await alterSelf(user.value.regNo,{password : toModify[element]}); + } } - toModify= Object.assign({}, pattern); + toModify= Object.assign({},pattern); + user.value = await getSelf() + + } + + function setModify(item){ + toModify.address = item.address; + toModify.profilPictureUrl = item.profilPictureUrl; + toModify.email= item.email; + toModify.password= item.password; } + async function unRegister(){ - disconnect(); + deleteUser(user.value.regNo); + disconnect() setTimeout(() => { window.location.href="#/home"; }, "500"); @@ -64,7 +81,7 @@ } function getPP(){ - if(user.profilePictureUrl === null){ + if(user.value.profilePictureUrl === null){ return "/Clyde.png" } return user.profilePictureUrl @@ -93,7 +110,7 @@ Role: {{i18n((user.role))}}
- +
@@ -110,23 +127,23 @@
E-mail: - +
{{i18n("profile.address")}}: - +
{{i18n("login.password")}}: - +
{{i18n("login.cPassword")}}: - +
- +
@@ -162,7 +179,7 @@
- +
diff --git a/frontend/src/Apps/StudentsList.vue b/frontend/src/Apps/StudentsList.vue index 89dae0b..cf4ef0e 100644 --- a/frontend/src/Apps/StudentsList.vue +++ b/frontend/src/Apps/StudentsList.vue @@ -4,7 +4,6 @@ import { getStudents } from '../rest/Users.js' const users = await getStudents(); - console.log(users)