From 160cfb0bbf1a07f68a7113b87063287c33a7bb2b Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sat, 9 Mar 2024 18:41:20 +0100 Subject: [PATCH 01/13] Page api stub --- frontend/src/rest/apps.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 frontend/src/rest/apps.js diff --git a/frontend/src/rest/apps.js b/frontend/src/rest/apps.js new file mode 100644 index 0000000..61fb716 --- /dev/null +++ b/frontend/src/rest/apps.js @@ -0,0 +1,9 @@ +import { restGet } from './restConsumer.js' + +export async function appList(){ + return restGet("/apps") +} + +export async function checkPage(page){ + return restGet("/apps/" + page) +} From 1f14890d435bc8bd3d0350616708dab09f777e4f Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Fri, 15 Mar 2024 18:54:53 +0100 Subject: [PATCH 02/13] added ApplicationController and Application enum --- .../EndPoints/ApplicationsController.java | 62 +++++++++++++++++++ .../herisson/Clyde/Tables/Applications.java | 24 +++++++ 2 files changed, 86 insertions(+) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java new file mode 100644 index 0000000..d044bf7 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -0,0 +1,62 @@ +package ovh.herisson.Clyde.EndPoints; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; +import ovh.herisson.Clyde.Services.AuthenticatorService; +import ovh.herisson.Clyde.Tables.Applications; +import ovh.herisson.Clyde.Tables.Role; + +import java.util.ArrayList; + +@RestController +public class ApplicationsController { + + AuthenticatorService authServ; + + public ApplicationsController(AuthenticatorService authServ){ + this.authServ = authServ; + } + + + /** return a list of authorized applications. + * depends on the token + */ + @GetMapping("/apps") + public ResponseEntity> getAuthorizedApps(@RequestHeader("Authorization") String token){ + + return new ResponseEntity<>(getAuthorizedApplications(token), HttpStatus.OK); + } + + @GetMapping("/apps/{identifier}") + public ResponseEntity getAppAuthorization(@PathVariable Applications identifier, @RequestHeader("Authorization") String token){ + + if (getAuthorizedApplications(token).contains(identifier)){ + return new ResponseEntity<>(true, HttpStatus.OK); + } + return new ResponseEntity<>(false, HttpStatus.OK); + } + + public ArrayList getAuthorizedApplications(String token){ + Role posterRole = authServ.getUserFromToken(token).getRole(); + ArrayList authorizedApps = new ArrayList<>(); + + authorizedApps.add(Applications.LOGIN); + authorizedApps.add(Applications.PROFILE); + authorizedApps.add(Applications.MSG); + authorizedApps.add(Applications.FORUM); + authorizedApps.add(Applications.RDV); + + if (posterRole == Role.Student || posterRole == Role.Admin) return authorizedApps; + + if (posterRole == Role.Teacher || posterRole == Role.Secretary || posterRole == Role.Admin) authorizedApps.add(Applications.MANAGECOURSES); + + if (posterRole == Role.InscriptionService || posterRole == Role.Admin) authorizedApps.add(Applications.INSCRIPTION); + + return authorizedApps; + } + +} \ No newline at end of file diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java new file mode 100644 index 0000000..445a928 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java @@ -0,0 +1,24 @@ +package ovh.herisson.Clyde.Tables; + +public enum Applications { + // without any token + LOGIN, + + // with any token + PROFILE, + + + // Students and higher authorization + MSG, + FORUM, + RDV, + + // teachers and Secretary authorization + MANAGECOURSES, + + // InscriptionService authorization + INSCRIPTION; + + + +} From 208c6c63e841daf5d2ff49f09dc1dbaa24c25163 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 00:31:03 +0100 Subject: [PATCH 03/13] moved the isSecretaryOrAdmin method --- .../Clyde/EndPoints/InscriptionController.java | 15 ++------------- .../herisson/Clyde/EndPoints/UserController.java | 16 ++-------------- .../Clyde/Services/AuthenticatorService.java | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java index a997c54..67ca1ee 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java @@ -31,7 +31,7 @@ public class InscriptionController { @GetMapping("/inscriptionRequests") public ResponseEntity>> getAllRequests(@RequestHeader("Authorization") String token){ - if (!isSecretaryOrAdmin(token)){return new UnauthorizedResponse<>(null);} + if (authServ.isNotSecretaryOrAdmin(token)){return new UnauthorizedResponse<>(null);} Iterable inscriptionRequests = inscriptionServ.getAll(); ArrayList> toReturn = new ArrayList<>(); @@ -70,15 +70,4 @@ public class InscriptionController { toReturn.put("state", inscriptionRequest.getState()); return toReturn; } - - - private boolean isSecretaryOrAdmin(String authorization){ - if (authorization ==null) - return false; - - User poster = authServ.getUserFromToken(authorization); - if (poster == null) return false; - - return poster.getRole() == Role.Secretary && poster.getRole() == Role.Admin; - } -} +} \ No newline at end of file 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 844e82e..d797284 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java @@ -43,7 +43,7 @@ public class UserController { @PostMapping("/user") public ResponseEntity postUser(@RequestBody User user,@RequestHeader("Authorization") String authorization){ - if (!isSecretaryOrAdmin(authorization)) + if (authServ.isNotSecretaryOrAdmin(authorization)) return new UnauthorizedResponse<>(null); userService.save(user); @@ -53,7 +53,7 @@ public class UserController { @GetMapping("/users") public ResponseEntity>> getAllUsers(@RequestHeader("Authorization") String authorization){ - if (!isSecretaryOrAdmin(authorization)) + if (authServ.isNotSecretaryOrAdmin(authorization)) return new UnauthorizedResponse<>(null); Iterable users = userService.getAll(); @@ -85,7 +85,6 @@ public class UserController { */ private HashMap userWithoutPassword(User user){ HashMap toReturn = new HashMap<>(); - toReturn.put("regNo",user.getRegNo()); toReturn.put("firstName",user.getFirstName()); toReturn.put("lastName",user.getLastName()); @@ -93,18 +92,7 @@ public class UserController { toReturn.put("country",user.getCountry()); toReturn.put("address",user.getAddress()); toReturn.put("role",user.getRole()); - return toReturn; } - - private boolean isSecretaryOrAdmin(String authorization){ - if (authorization ==null) - return false; - - User poster = authServ.getUserFromToken(authorization); - if (poster == null) return false; - - return poster.getRole() == Role.Secretary && poster.getRole() == Role.Admin; - } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java index 60dc6bc..1cc18e1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java @@ -4,6 +4,7 @@ import org.springframework.stereotype.Service; import ovh.herisson.Clyde.EndPoints.LoginController; import ovh.herisson.Clyde.Repositories.InscriptionRepository; import ovh.herisson.Clyde.Tables.InscriptionRequest; +import ovh.herisson.Clyde.Tables.Role; import ovh.herisson.Clyde.Tables.Token; import ovh.herisson.Clyde.Tables.User; @@ -39,4 +40,17 @@ public class AuthenticatorService { public void register(InscriptionRequest inscriptionRequest) { inscriptionService.save(inscriptionRequest); } + + + public boolean isNotSecretaryOrAdmin(String authorization){ + if (authorization ==null) + return true; + + User poster = getUserFromToken(authorization); + if (poster == null) return true; + + return poster.getRole() != Role.Secretary || poster.getRole() != Role.Admin; + } + } + From 25009ba149938c74594d53088e7c52ea5ad0fd16 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 00:34:20 +0100 Subject: [PATCH 04/13] Enum in CamelCase --- .../Clyde/EndPoints/ApplicationsController.java | 14 +++++++------- .../ovh/herisson/Clyde/Tables/Applications.java | 17 +++++++---------- .../ovh/herisson/Clyde/Tables/CursusType.java | 6 +++--- .../ovh/herisson/Clyde/Tables/RequestState.java | 2 +- .../java/ovh/herisson/Clyde/Tables/Role.java | 4 ++-- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java index d044bf7..9bd32c1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -44,17 +44,17 @@ public class ApplicationsController { Role posterRole = authServ.getUserFromToken(token).getRole(); ArrayList authorizedApps = new ArrayList<>(); - authorizedApps.add(Applications.LOGIN); - authorizedApps.add(Applications.PROFILE); - authorizedApps.add(Applications.MSG); - authorizedApps.add(Applications.FORUM); - authorizedApps.add(Applications.RDV); + authorizedApps.add(Applications.Login); + authorizedApps.add(Applications.Profile); + authorizedApps.add(Applications.Msg); + authorizedApps.add(Applications.Forum); + authorizedApps.add(Applications.Rdv); if (posterRole == Role.Student || posterRole == Role.Admin) return authorizedApps; - if (posterRole == Role.Teacher || posterRole == Role.Secretary || posterRole == Role.Admin) authorizedApps.add(Applications.MANAGECOURSES); + if (posterRole == Role.Teacher || posterRole == Role.Secretary || posterRole == Role.Admin) authorizedApps.add(Applications.ManageCourses); - if (posterRole == Role.InscriptionService || posterRole == Role.Admin) authorizedApps.add(Applications.INSCRIPTION); + if (posterRole == Role.InscriptionService || posterRole == Role.Admin) authorizedApps.add(Applications.Inscription); return authorizedApps; } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java index 445a928..6ad6567 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java @@ -2,23 +2,20 @@ package ovh.herisson.Clyde.Tables; public enum Applications { // without any token - LOGIN, + Login, // with any token - PROFILE, + Profile, // Students and higher authorization - MSG, - FORUM, - RDV, + Msg, + Forum, + Rdv, // teachers and Secretary authorization - MANAGECOURSES, + ManageCourses, // InscriptionService authorization - INSCRIPTION; - - - + Inscription } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusType.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusType.java index 5e9c50f..d99d47e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusType.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusType.java @@ -2,7 +2,7 @@ package ovh.herisson.Clyde.Tables; public enum CursusType { - infoBab1, - chemistryBab1, - psychologyBab1; + InfoBab1, + ChemistryBab1, + PsychologyBab1 } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java index f0345c1..d52f1c9 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java @@ -3,5 +3,5 @@ package ovh.herisson.Clyde.Tables; public enum RequestState { Accepted, Refused, - Pending; + Pending } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java index 4e4469b..f6f8967 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java @@ -5,5 +5,5 @@ public enum Role { Student, Admin, InscriptionService, - Secretary; -} + Secretary +} \ No newline at end of file From 0860567e1b9d0ccbb85cb7c05bcad3359e0df04a Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 00:42:46 +0100 Subject: [PATCH 05/13] fixed the GetAuthorizedApps method --- .../Clyde/EndPoints/ApplicationsController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java index d044bf7..d5ad171 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -46,11 +46,12 @@ public class ApplicationsController { authorizedApps.add(Applications.LOGIN); authorizedApps.add(Applications.PROFILE); - authorizedApps.add(Applications.MSG); - authorizedApps.add(Applications.FORUM); - authorizedApps.add(Applications.RDV); - if (posterRole == Role.Student || posterRole == Role.Admin) return authorizedApps; + if (posterRole == Role.Teacher || posterRole == Role.Student || posterRole == Role.Admin){ + authorizedApps.add(Applications.MSG); + authorizedApps.add(Applications.FORUM); + authorizedApps.add(Applications.RDV); + } if (posterRole == Role.Teacher || posterRole == Role.Secretary || posterRole == Role.Admin) authorizedApps.add(Applications.MANAGECOURSES); @@ -58,5 +59,4 @@ public class ApplicationsController { return authorizedApps; } - } \ No newline at end of file From b7b2eafb933d9a1cac369dc24f68451459d91591 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 00:44:11 +0100 Subject: [PATCH 06/13] removed the GET /Apps/{id} frontend just iterates on the /apps list --- .../Clyde/EndPoints/ApplicationsController.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java index d5ad171..c76d513 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -31,16 +31,7 @@ public class ApplicationsController { return new ResponseEntity<>(getAuthorizedApplications(token), HttpStatus.OK); } - @GetMapping("/apps/{identifier}") - public ResponseEntity getAppAuthorization(@PathVariable Applications identifier, @RequestHeader("Authorization") String token){ - - if (getAuthorizedApplications(token).contains(identifier)){ - return new ResponseEntity<>(true, HttpStatus.OK); - } - return new ResponseEntity<>(false, HttpStatus.OK); - } - - public ArrayList getAuthorizedApplications(String token){ + private ArrayList getAuthorizedApplications(String token){ Role posterRole = authServ.getUserFromToken(token).getRole(); ArrayList authorizedApps = new ArrayList<>(); From 13fd048cd28f2efc59a6b7a4112343761aed28b9 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 09:01:36 +0100 Subject: [PATCH 07/13] added a inscriptionService mock user --- .../main/java/ovh/herisson/Clyde/EndPoints/MockController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 136cecd..f3ea51d 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -43,7 +43,8 @@ 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.Teacher,passwordEncoder.encode("secretary")); User joke = new User("CthemBalls","Lemme","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); - mockUsers = new ArrayList(Arrays.asList(herobrine,joe,meh,joke)); + User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.Teacher,passwordEncoder.encode("inscriptionService")); + mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke)); userRepo.saveAll(mockUsers); } From c6198b7220931156195ebeb7901cd3cda13dd926 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 09:02:08 +0100 Subject: [PATCH 08/13] cleaned Services + added private final to all repos --- .../Clyde/Services/AuthenticatorService.java | 2 -- .../herisson/Clyde/Services/InscriptionService.java | 13 +++++-------- .../ovh/herisson/Clyde/Services/StorageService.java | 2 -- .../ovh/herisson/Clyde/Services/TokenService.java | 4 +--- .../main/java/ovh/herisson/Clyde/Tables/Course.java | 2 +- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java index 1cc18e1..a3301c1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java @@ -1,8 +1,6 @@ package ovh.herisson.Clyde.Services; import org.springframework.stereotype.Service; -import ovh.herisson.Clyde.EndPoints.LoginController; -import ovh.herisson.Clyde.Repositories.InscriptionRepository; import ovh.herisson.Clyde.Tables.InscriptionRequest; import ovh.herisson.Clyde.Tables.Role; import ovh.herisson.Clyde.Tables.Token; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java index 45495b7..318dfc1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java @@ -4,23 +4,20 @@ import org.springframework.stereotype.Service; import ovh.herisson.Clyde.Repositories.InscriptionRepository; import ovh.herisson.Clyde.Tables.InscriptionRequest; -import java.util.HashMap; -import java.util.Map; - @Service public class InscriptionService { - InscriptionRepository incriptionRepo; + private final InscriptionRepository inscriptionRepo; public void save(InscriptionRequest inscriptionRequest){ - incriptionRepo.save(inscriptionRequest); + inscriptionRepo.save(inscriptionRequest); } public InscriptionService(InscriptionRepository inscriptionRepo){ - this.incriptionRepo = inscriptionRepo; + this.inscriptionRepo = inscriptionRepo; } public InscriptionRequest getById(long id){ - InscriptionRequest inscriptionRequest = incriptionRepo.findById(id); + InscriptionRequest inscriptionRequest = inscriptionRepo.findById(id); if (inscriptionRequest == null){ return null; @@ -29,6 +26,6 @@ public class InscriptionService { } public Iterable getAll(){ - return incriptionRepo.findAll(); + return inscriptionRepo.findAll(); } } \ No newline at end of file diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java index c7f8d1b..fb04f68 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java @@ -4,10 +4,8 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import ovh.herisson.Clyde.Repositories.FileRepository; import ovh.herisson.Clyde.Tables.*; - import java.io.File; import java.io.IOException; - import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java index 50ddcbf..ce0d109 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java @@ -5,16 +5,14 @@ import org.springframework.stereotype.Service; import ovh.herisson.Clyde.Repositories.TokenRepository; import ovh.herisson.Clyde.Tables.Token; import ovh.herisson.Clyde.Tables.User; - import java.io.UnsupportedEncodingException; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Calendar; -import java.util.Date; @Service public class TokenService { - TokenRepository tokenRepo; + private final TokenRepository tokenRepo; public TokenService(TokenRepository tokenRepo){ this.tokenRepo = tokenRepo; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java index 54e167a..fb11604 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java @@ -1,6 +1,6 @@ package ovh.herisson.Clyde.Tables; -import jakarta.persistence.Entity; +import ja karta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; From 8f2fb041129f83e717d2b382b831f47b4eef1a7f Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 09:03:03 +0100 Subject: [PATCH 09/13] I pressed tab by accident --- backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java index fb11604..54e167a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java @@ -1,6 +1,6 @@ package ovh.herisson.Clyde.Tables; -import ja karta.persistence.Entity; +import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; From 45fbef52edd3034c6036a8f7055ee6dbfede031f Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sat, 16 Mar 2024 12:29:51 +0100 Subject: [PATCH 10/13] fix tokens characters --- .../main/java/ovh/herisson/Clyde/Services/TokenService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java index 50ddcbf..8c9e2d6 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java @@ -9,6 +9,7 @@ import ovh.herisson.Clyde.Tables.User; import java.io.UnsupportedEncodingException; import java.security.SecureRandom; import java.util.ArrayList; +import java.util.Base64; import java.util.Calendar; import java.util.Date; @@ -30,13 +31,10 @@ public class TokenService { new SecureRandom().nextBytes(bytes); for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) (((bytes[i]+256)%256 %95+ 32)); - while ((char)bytes[i] == ';'){ - bytes[i] = new SecureRandom().generateSeed(1)[0]; - } } // will never end up in the catch because of the way that SecureRandom.nextBytes is implemented try { - return new String(bytes,"ISO_8859_1"); + return new String(Base64.getEncoder().encode(bytes),"ISO_8859_1"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } From 847936b799082589ba6c50d13cda0cbca2d37557 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sat, 16 Mar 2024 12:29:51 +0100 Subject: [PATCH 11/13] fix tokens characters --- .../main/java/ovh/herisson/Clyde/Services/TokenService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java index 50ddcbf..8c9e2d6 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java @@ -9,6 +9,7 @@ import ovh.herisson.Clyde.Tables.User; import java.io.UnsupportedEncodingException; import java.security.SecureRandom; import java.util.ArrayList; +import java.util.Base64; import java.util.Calendar; import java.util.Date; @@ -30,13 +31,10 @@ public class TokenService { new SecureRandom().nextBytes(bytes); for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) (((bytes[i]+256)%256 %95+ 32)); - while ((char)bytes[i] == ';'){ - bytes[i] = new SecureRandom().generateSeed(1)[0]; - } } // will never end up in the catch because of the way that SecureRandom.nextBytes is implemented try { - return new String(bytes,"ISO_8859_1"); + return new String(Base64.getEncoder().encode(bytes),"ISO_8859_1"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } From 04f64f505e23bddf710c69214d59890a0efc9595 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sat, 16 Mar 2024 13:56:29 +0100 Subject: [PATCH 12/13] Indicated that you are logged by coloring the icon in orange and disconnect if clicked on it --- frontend/src/App.vue | 10 +++++++--- frontend/src/Apps/Login.vue | 5 ++++- frontend/src/rest/Users.js | 9 +++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 7b944de..1163b03 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -2,6 +2,7 @@ import { toast } from 'vue3-toastify'; import { ref, computed } from 'vue' import i18n, { setLang } from './i18n.js' + import { isLogged } from '@/rest/Users.js' // Liste des apps @@ -19,6 +20,7 @@ const currentPath = ref(window.location.hash) window.addEventListener('hashchange', () => { + Logged.value = isLogged(); currentPath.value = window.location.hash }) @@ -31,7 +33,9 @@ const settings=ref(i18n("app.settings")) const login=ref(i18n("app.login")) const active=ref(false) - + + const Logged = ref(isLogged()); +