Compare commits
No commits in common. "92079c5a47177af986a016cb1d4548b7cc369467" and "8ff29ca34e89ab8bcf6cb5bde7dbf8055fbbccfa" have entirely different histories.
92079c5a47
...
8ff29ca34e
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 29 KiB |
@ -11,6 +11,7 @@ import ovh.herisson.Clyde.Services.TeacherCourseService;
|
|||||||
import ovh.herisson.Clyde.Tables.Course;
|
import ovh.herisson.Clyde.Tables.Course;
|
||||||
import ovh.herisson.Clyde.Tables.Role;
|
import ovh.herisson.Clyde.Tables.Role;
|
||||||
import ovh.herisson.Clyde.Tables.User;
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -119,20 +120,4 @@ public class CourseController {
|
|||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@DeleteMapping("course/{id}")
|
|
||||||
public ResponseEntity<String> deleteUser(@RequestHeader("Authorization") String token, @PathVariable Long id){
|
|
||||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary}, token))
|
|
||||||
return new UnauthorizedResponse<>(null);
|
|
||||||
|
|
||||||
Course toDelete = courseServ.findById(id);
|
|
||||||
|
|
||||||
if (toDelete == null)
|
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
|
||||||
|
|
||||||
|
|
||||||
courseServ.delete(courseServ.findById(id));
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -67,18 +67,4 @@ public class CurriculumController {
|
|||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/curriculum/{id}")
|
|
||||||
public ResponseEntity<String > deleteCurriculum(@RequestHeader("Authorization") String token, @PathVariable Long id){
|
|
||||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary}, token))
|
|
||||||
return new UnauthorizedResponse<>(null);
|
|
||||||
|
|
||||||
Curriculum toDelete = curriculumServ.findById(id);
|
|
||||||
|
|
||||||
if (toDelete == null)
|
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
|
||||||
|
|
||||||
curriculumServ.delete(toDelete);
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,11 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||||
import ovh.herisson.Clyde.Services.InscriptionService;
|
import ovh.herisson.Clyde.Services.InscriptionService;
|
||||||
import ovh.herisson.Clyde.Services.ProtectionService;
|
|
||||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||||
import ovh.herisson.Clyde.Tables.RequestState;
|
import ovh.herisson.Clyde.Tables.RequestState;
|
||||||
import ovh.herisson.Clyde.Tables.Role;
|
import ovh.herisson.Clyde.Tables.Role;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -33,8 +34,13 @@ public class InscriptionController {
|
|||||||
return new UnauthorizedResponse<>(null);
|
return new UnauthorizedResponse<>(null);
|
||||||
|
|
||||||
Iterable<InscriptionRequest> inscriptionRequests = inscriptionServ.getAll();
|
Iterable<InscriptionRequest> inscriptionRequests = inscriptionServ.getAll();
|
||||||
|
ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
|
||||||
|
|
||||||
return new ResponseEntity<>(ProtectionService.requestsWithoutPasswords(inscriptionRequests), HttpStatus.OK);
|
for (InscriptionRequest i:inscriptionRequests){
|
||||||
|
toReturn.add(requestWithoutPassword(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -49,35 +55,38 @@ public class InscriptionController {
|
|||||||
if (foundInscriptionRequest == null)
|
if (foundInscriptionRequest == null)
|
||||||
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
|
||||||
|
|
||||||
return new ResponseEntity<>(ProtectionService.requestWithoutPassword(foundInscriptionRequest), HttpStatus.OK);
|
return new ResponseEntity<>(requestWithoutPassword(foundInscriptionRequest), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/request/register/{id}")
|
@PatchMapping("/request/register/{id}")
|
||||||
public ResponseEntity<InscriptionRequest> changeRequestState(@PathVariable long id,
|
public ResponseEntity<InscriptionRequest> changeRequestState(@PathVariable long id,
|
||||||
@RequestHeader("Authorization") String token,
|
@RequestHeader("Authorization") String token,
|
||||||
@RequestBody RequestState state)
|
@RequestBody RequestState requestState)
|
||||||
{
|
{
|
||||||
System.out.println(requestState);
|
|
||||||
if (authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin},token))
|
if (authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin},token))
|
||||||
return new UnauthorizedResponse<>(null);
|
return new UnauthorizedResponse<>(null);
|
||||||
|
|
||||||
if (!inscriptionServ.modifyState(id, state))
|
if (!inscriptionServ.modifyState(id, requestState))
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@DeleteMapping("/request/register/{id}")
|
|
||||||
public ResponseEntity<String > deleteRequest(@RequestHeader("Authorization") String token, @PathVariable Long id){
|
|
||||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService}, token))
|
|
||||||
return new UnauthorizedResponse<>(null);
|
|
||||||
|
|
||||||
InscriptionRequest toDelete = inscriptionServ.getById(id);
|
private Map<String, Object> requestWithoutPassword(InscriptionRequest inscriptionRequest) {
|
||||||
|
Map<String, Object> toReturn = new HashMap<>();
|
||||||
|
|
||||||
if (toDelete == null)
|
toReturn.put("id", inscriptionRequest.getId());
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
toReturn.put("lastName", inscriptionRequest.getLastName());
|
||||||
|
toReturn.put("firstName", inscriptionRequest.getFirstName());
|
||||||
|
toReturn.put("address", inscriptionRequest.getAddress());
|
||||||
|
toReturn.put("email",inscriptionRequest.getEmail());
|
||||||
|
toReturn.put("birthDate", inscriptionRequest.getBirthDate());
|
||||||
|
toReturn.put("country", inscriptionRequest.getCountry());
|
||||||
|
toReturn.put("curriculum", inscriptionRequest.getCurriculumId());
|
||||||
|
toReturn.put("state", inscriptionRequest.getState());
|
||||||
|
toReturn.put("profilePictureUrl", inscriptionRequest.getProfilePicture());
|
||||||
|
|
||||||
inscriptionServ.delete(toDelete);
|
return toReturn;
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,8 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||||
import ovh.herisson.Clyde.Services.ProtectionService;
|
|
||||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||||
@ -47,10 +45,7 @@ public class LoginController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public ResponseEntity<Map<String,Object>> register(@RequestBody InscriptionRequest inscriptionRequest){
|
public ResponseEntity<InscriptionRequest> register(@RequestBody InscriptionRequest inscriptionRequest){
|
||||||
|
return new ResponseEntity<>(authServ.register(inscriptionRequest), HttpStatus.CREATED);
|
||||||
InscriptionRequest returnedInscriptionRequest = authServ.register(inscriptionRequest);
|
|
||||||
|
|
||||||
return new ResponseEntity<>(ProtectionService.requestWithoutPassword(returnedInscriptionRequest), HttpStatus.CREATED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,16 @@ public class MockController {
|
|||||||
public final CurriculumCourseService CurriculumCourseService;
|
public final CurriculumCourseService CurriculumCourseService;
|
||||||
public final CurriculumService curriculumService;
|
public final CurriculumService curriculumService;
|
||||||
public final CourseService courseService;
|
public final CourseService courseService;
|
||||||
|
|
||||||
public final InscriptionService inscriptionService;
|
|
||||||
ArrayList<User> mockUsers;
|
ArrayList<User> mockUsers;
|
||||||
|
|
||||||
|
|
||||||
public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService){
|
public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService){
|
||||||
this.tokenRepo = tokenRepo;
|
this.tokenRepo = tokenRepo;
|
||||||
this.userRepo = userRepo;
|
this.userRepo = userRepo;
|
||||||
this.tokenService = tokenService;
|
this.tokenService = tokenService;
|
||||||
this.CurriculumCourseService = CurriculumCourseService;
|
this.CurriculumCourseService = CurriculumCourseService;
|
||||||
this.curriculumService = curriculumService;
|
this.curriculumService = curriculumService;
|
||||||
this.courseService = courseService;
|
this.courseService = courseService;
|
||||||
this.inscriptionService = inscriptionService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Saves an example of each user type by :
|
/** Saves an example of each user type by :
|
||||||
@ -90,11 +87,6 @@ public class MockController {
|
|||||||
CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,commun));
|
CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,commun));
|
||||||
CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1));
|
CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1));
|
||||||
|
|
||||||
|
|
||||||
InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 1,RequestState.Refused,"yes.png","password");
|
|
||||||
|
|
||||||
inscriptionService.save(inscriptionRequest);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,19 +121,4 @@ public class UserController {
|
|||||||
|
|
||||||
return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(students), HttpStatus.OK);
|
return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(students), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@DeleteMapping("/user/{id}")
|
|
||||||
public ResponseEntity<String> deleteStudent(@RequestHeader("Authorization") String token, @PathVariable Long id){
|
|
||||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
|
||||||
return new UnauthorizedResponse<>(null);
|
|
||||||
|
|
||||||
User toDelete = userService.getUserById(id);
|
|
||||||
|
|
||||||
if (toDelete == null)
|
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
|
||||||
|
|
||||||
userService.delete(toDelete);
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ public class AuthenticatorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public InscriptionRequest register(InscriptionRequest inscriptionRequest) {
|
public InscriptionRequest register(InscriptionRequest inscriptionRequest) {
|
||||||
inscriptionRequest.setState(RequestState.Pending);
|
|
||||||
return inscriptionService.save(inscriptionRequest);
|
return inscriptionService.save(inscriptionRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,4 @@ public class CourseService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(Course course) {
|
|
||||||
courseRepo.delete(course);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,4 @@ public class CurriculumService {
|
|||||||
return curriculumRepo.findById(id);
|
return curriculumRepo.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(Curriculum curriculum) {
|
|
||||||
curriculumRepo.delete(curriculum);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -87,8 +87,4 @@ public class InscriptionService {
|
|||||||
save(inscrRequest);
|
save(inscrRequest);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(InscriptionRequest toDelete) {
|
|
||||||
inscriptionRepo.delete(toDelete);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package ovh.herisson.Clyde.Services;
|
package ovh.herisson.Clyde.Services;
|
||||||
|
|
||||||
import ovh.herisson.Clyde.Tables.Course;
|
import ovh.herisson.Clyde.Tables.Course;
|
||||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
|
||||||
import ovh.herisson.Clyde.Tables.User;
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ProtectionService {
|
public class ProtectionService {
|
||||||
|
|
||||||
@ -15,10 +13,6 @@ public class ProtectionService {
|
|||||||
* @return all the user data without the password
|
* @return all the user data without the password
|
||||||
*/
|
*/
|
||||||
public static HashMap<String,Object> userWithoutPassword(User user){
|
public static HashMap<String,Object> userWithoutPassword(User user){
|
||||||
|
|
||||||
if (user ==null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
HashMap<String,Object> toReturn = new HashMap<>();
|
HashMap<String,Object> toReturn = new HashMap<>();
|
||||||
|
|
||||||
toReturn.put("regNo",user.getRegNo());
|
toReturn.put("regNo",user.getRegNo());
|
||||||
@ -46,9 +40,6 @@ public class ProtectionService {
|
|||||||
|
|
||||||
|
|
||||||
public static HashMap<String,Object> courseWithoutPassword(Course course){
|
public static HashMap<String,Object> courseWithoutPassword(Course course){
|
||||||
if (course == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
HashMap<String ,Object> toReturn = new HashMap<>();
|
HashMap<String ,Object> toReturn = new HashMap<>();
|
||||||
|
|
||||||
toReturn.put("courseId",course.getCourseID());
|
toReturn.put("courseId",course.getCourseID());
|
||||||
@ -70,36 +61,5 @@ public class ProtectionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Map<String, Object> requestWithoutPassword(InscriptionRequest inscriptionRequest) {
|
|
||||||
|
|
||||||
if (inscriptionRequest == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Map<String, Object> toReturn = new HashMap<>();
|
|
||||||
|
|
||||||
toReturn.put("id", inscriptionRequest.getId());
|
|
||||||
toReturn.put("lastName", inscriptionRequest.getLastName());
|
|
||||||
toReturn.put("firstName", inscriptionRequest.getFirstName());
|
|
||||||
toReturn.put("address", inscriptionRequest.getAddress());
|
|
||||||
toReturn.put("email",inscriptionRequest.getEmail());
|
|
||||||
toReturn.put("birthDate", inscriptionRequest.getBirthDate());
|
|
||||||
toReturn.put("country", inscriptionRequest.getCountry());
|
|
||||||
toReturn.put("curriculum", inscriptionRequest.getCurriculumId());
|
|
||||||
toReturn.put("state", inscriptionRequest.getState());
|
|
||||||
toReturn.put("profilePictureUrl", inscriptionRequest.getProfilePicture());
|
|
||||||
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Iterable<Map<String ,Object>> requestsWithoutPasswords(Iterable<InscriptionRequest> inscriptionRequests){
|
|
||||||
|
|
||||||
ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
|
|
||||||
|
|
||||||
for (InscriptionRequest i:inscriptionRequests){
|
|
||||||
toReturn.add(requestWithoutPassword(i));
|
|
||||||
}
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,8 +127,4 @@ public class UserService {
|
|||||||
public User getUserById(long id) {
|
public User getUserById(long id) {
|
||||||
return userRepo.findById(id);
|
return userRepo.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(User user) {
|
|
||||||
userRepo.delete(user);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package ovh.herisson.Clyde.Tables;
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import org.hibernate.annotations.OnDelete;
|
|
||||||
import org.hibernate.annotations.OnDeleteAction;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Course {
|
public class Course {
|
||||||
@ -13,7 +11,6 @@ public class Course {
|
|||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@OnDelete(action = OnDeleteAction.SET_NULL)
|
|
||||||
@JoinColumn(name = "Users")
|
@JoinColumn(name = "Users")
|
||||||
private User owner;
|
private User owner;
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package ovh.herisson.Clyde.Tables;
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import org.hibernate.annotations.OnDelete;
|
|
||||||
import org.hibernate.annotations.OnDeleteAction;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class CurriculumCourse {
|
public class CurriculumCourse {
|
||||||
@ -12,11 +10,9 @@ public class CurriculumCourse {
|
|||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "Curriculum")
|
@JoinColumn(name = "Curriculum")
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
private Curriculum curriculum;
|
private Curriculum curriculum;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
@JoinColumn(name = "Course")
|
@JoinColumn(name = "Course")
|
||||||
private Course course;
|
private Course course;
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package ovh.herisson.Clyde.Tables;
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import org.hibernate.annotations.OnDelete;
|
|
||||||
import org.hibernate.annotations.OnDeleteAction;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class ReInscriptionRequest {
|
public class ReInscriptionRequest {
|
||||||
@ -12,12 +10,10 @@ public class ReInscriptionRequest {
|
|||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "Users")
|
@JoinColumn(name = "Users")
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "Curriculum")
|
@JoinColumn(name = "Curriculum")
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
private Curriculum newCurriculum;
|
private Curriculum newCurriculum;
|
||||||
private RequestState state;
|
private RequestState state;
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package ovh.herisson.Clyde.Tables;
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import org.hibernate.annotations.OnDelete;
|
|
||||||
import org.hibernate.annotations.OnDeleteAction;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class TeacherCourse {
|
public class TeacherCourse {
|
||||||
@ -11,13 +9,11 @@ public class TeacherCourse {
|
|||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
@JoinColumn(name = "Users")
|
@JoinColumn(name = "Users")
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
@JoinColumn(name = "Course")
|
@JoinColumn(name = "Course")
|
||||||
private Course course;
|
private Course course;
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package ovh.herisson.Clyde.Tables;
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import org.hibernate.annotations.OnDelete;
|
|
||||||
import org.hibernate.annotations.OnDeleteAction;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ -13,7 +11,6 @@ public class Token {
|
|||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
@JoinColumn(name ="Users")
|
@JoinColumn(name ="Users")
|
||||||
private User user;
|
private User user;
|
||||||
private String token;
|
private String token;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package ovh.herisson.Clyde.Tables;
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import org.hibernate.annotations.OnDelete;
|
|
||||||
import org.hibernate.annotations.OnDeleteAction;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class UserCurriculum {
|
public class UserCurriculum {
|
||||||
@ -12,13 +10,11 @@ public class UserCurriculum {
|
|||||||
|
|
||||||
//Un étudiant peut avoir plusieurs curriculums
|
//Un étudiant peut avoir plusieurs curriculums
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
@JoinColumn(name = "Users")
|
@JoinColumn(name = "Users")
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@OneToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "Curriculum")
|
@JoinColumn(name = "Curriculum")
|
||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
|
||||||
private Curriculum curriculum;
|
private Curriculum curriculum;
|
||||||
|
|
||||||
public UserCurriculum(User user, Curriculum curriculum){
|
public UserCurriculum(User user, Curriculum curriculum){
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import i18n from "@/i18n.js"
|
import i18n from "@/i18n.js"
|
||||||
|
import Req from "./Request.vue"
|
||||||
import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'
|
import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'
|
||||||
|
|
||||||
const requests_example = await getAllRegisters();
|
const requests_example = await getAllRegisters();
|
||||||
@ -17,8 +18,8 @@
|
|||||||
<div class="surname"><a>{{item.lastName}}</a></div>
|
<div class="surname"><a>{{item.lastName}}</a></div>
|
||||||
<div class="firstname"><a>{{item.firstName}}</a></div>
|
<div class="firstname"><a>{{item.firstName}}</a></div>
|
||||||
<div class="infos"><button style="background-color:rgb(105,05,105);" >{{i18n("request.moreInfos")}}</button></div>
|
<div class="infos"><button style="background-color:rgb(105,05,105);" >{{i18n("request.moreInfos")}}</button></div>
|
||||||
<div class="accept"><button @click="validateRegister(item.id,'Accepted')" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
|
<div class="accept"><button @click="validateRegister(id,Accepted)" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
|
||||||
<div class="refuse"><button @click="validateRegister(item.id,Refused)" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div>
|
<div class="refuse"><button @click="validateRegister(id,Refused)" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {reactive, ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import i18n from '@/i18n.js'
|
import i18n from '@/i18n.js'
|
||||||
import { login , register , disconnect, isLogged} from '@/rest/Users.js'
|
import { login , register , disconnect, isLogged} from '@/rest/Users.js'
|
||||||
import { getAllCurriculums } from '@/rest/curriculum.js'
|
import { getAllCurriculums } from '@/rest/curriculum.js'
|
||||||
@ -11,19 +11,16 @@
|
|||||||
const loginPage= ref(true)
|
const loginPage= ref(true)
|
||||||
const page = ref(0)
|
const page = ref(0)
|
||||||
|
|
||||||
const outputs = reactive({
|
|
||||||
surname:null,
|
|
||||||
firstname:null,
|
|
||||||
password:null,
|
|
||||||
birthday:null,
|
|
||||||
email:null,
|
|
||||||
address:null,
|
|
||||||
country:null,
|
|
||||||
curriculum:null,
|
|
||||||
})
|
|
||||||
|
|
||||||
const submitValue= ref(i18n("login.guest.submit"))
|
const submitValue= ref(i18n("login.guest.submit"))
|
||||||
|
const surname=ref("")
|
||||||
|
const firstname=ref("")
|
||||||
|
const password=ref("")
|
||||||
const passwordConfirm=ref("")
|
const passwordConfirm=ref("")
|
||||||
|
const birthday=ref("")
|
||||||
|
const email=ref("")
|
||||||
|
const address=ref("")
|
||||||
|
const country=ref("")
|
||||||
|
let curriculum;
|
||||||
|
|
||||||
const imageSaved = ref(false)
|
const imageSaved = ref(false)
|
||||||
const ppData = ref(false)
|
const ppData = ref(false)
|
||||||
@ -35,9 +32,8 @@
|
|||||||
window.location.href="#/home";
|
window.location.href="#/home";
|
||||||
}, "500");
|
}, "500");
|
||||||
}
|
}
|
||||||
function verifyInputs(pass){
|
function verifyInputs(){
|
||||||
console.log(pass)
|
if(password.value==passwordConfirm.value){
|
||||||
if(pass==passwordConfirm.value){
|
|
||||||
page.value++;
|
page.value++;
|
||||||
return toast('Password and Confirm Password are correct.', {
|
return toast('Password and Confirm Password are correct.', {
|
||||||
|
|
||||||
@ -60,17 +56,17 @@
|
|||||||
<div class='loginBox'>
|
<div class='loginBox'>
|
||||||
|
|
||||||
<div v-if="loginPage">
|
<div v-if="loginPage">
|
||||||
<form @submit.prevent=" login(outputs.email,outputs.password);goBackHome();"class="form">
|
<form @submit.prevent=" login(email,password);goBackHome();"class="form">
|
||||||
<h1 style="color:rgb(239,60,168); font-family: sans-serif;">
|
<h1 style="color:rgb(239,60,168); font-family: sans-serif;">
|
||||||
{{i18n("login.guest.signin")}}
|
{{i18n("login.guest.signin")}}
|
||||||
</h1>
|
</h1>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>ID / {{i18n("login.guest.email")}}</p>
|
<p>ID / {{i18n("login.guest.email")}}</p>
|
||||||
<input type="text" v-model="outputs.email">
|
<input type="text" v-model="email">
|
||||||
</div>
|
</div>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("login.guest.password")}}</p>
|
<p>{{i18n("login.guest.password")}}</p>
|
||||||
<input type="password" v-model="outputs.password">
|
<input type="password" v-model="password">
|
||||||
</div>
|
</div>
|
||||||
<div class="register">
|
<div class="register">
|
||||||
<a @click="loginPage=!loginPage">{{i18n("login.guest.register")}}</a>
|
<a @click="loginPage=!loginPage">{{i18n("login.guest.register")}}</a>
|
||||||
@ -89,19 +85,19 @@
|
|||||||
<div v-if="page === 0">
|
<div v-if="page === 0">
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("login.guest.surname")}}</p>
|
<p>{{i18n("login.guest.surname")}}</p>
|
||||||
<input type="text" v-model="outputs.surname">
|
<input type="text" v-model="surname">
|
||||||
</div>
|
</div>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("login.guest.firstname")}}</p>
|
<p>{{i18n("login.guest.firstname")}}</p>
|
||||||
<input type="text" v-model="outputs.firstname">
|
<input type="text" v-model="firstname">
|
||||||
</div>
|
</div>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("login.guest.birthday")}}</p>
|
<p>{{i18n("login.guest.birthday")}}</p>
|
||||||
<input type="date" v-model="outputs.birthday">
|
<input type="date" v-model="birthday">
|
||||||
</div>
|
</div>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("login.guest.password")}}</p>
|
<p>{{i18n("login.guest.password")}}</p>
|
||||||
<input type="password" v-model="outputs.password">
|
<input type="password" v-model="password">
|
||||||
</div>
|
</div>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("login.guest.confirm")}} {{i18n("login.guest.password")}}</p>
|
<p>{{i18n("login.guest.confirm")}} {{i18n("login.guest.password")}}</p>
|
||||||
@ -109,7 +105,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="switchpage">
|
<div class="switchpage">
|
||||||
<button @click="verifyInputs(outputs.password);">{{i18n("login.guest.nextpage")}}</button>
|
<button @click="verifyInputs();">{{i18n("login.guest.nextpage")}}</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div @click="(loginPage=!loginPage) && (page=0)" class="register">
|
<div @click="(loginPage=!loginPage) && (page=0)" class="register">
|
||||||
@ -119,15 +115,15 @@
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("login.guest.email")}}</p>
|
<p>{{i18n("login.guest.email")}}</p>
|
||||||
<input type="mail" v-model="outputs.email">
|
<input type="mail" v-model="email">
|
||||||
</div>
|
</div>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("login.guest.address")}}</p>
|
<p>{{i18n("login.guest.address")}}</p>
|
||||||
<input type="text" v-model="outputs.address">
|
<input type="text" v-model="address">
|
||||||
</div>
|
</div>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("login.guest.country")}}</p>
|
<p>{{i18n("login.guest.country")}}</p>
|
||||||
<input type="text" v-model="outputs.country">
|
<input type="text" v-model="country">
|
||||||
</div>
|
</div>
|
||||||
<form novalidate enctype="multipart/form-data" class="inputBox">
|
<form novalidate enctype="multipart/form-data" class="inputBox">
|
||||||
<p>{{i18n("profile.picture").toUpperCase()}}</p>
|
<p>{{i18n("profile.picture").toUpperCase()}}</p>
|
||||||
@ -135,13 +131,13 @@
|
|||||||
</form>
|
</form>
|
||||||
<div class="inputBox">
|
<div class="inputBox">
|
||||||
<p>{{i18n("Curriculum").toUpperCase()}}</p>
|
<p>{{i18n("Curriculum").toUpperCase()}}</p>
|
||||||
<select v-model="outputs.curriculum">
|
<select v-model="curriculum">
|
||||||
<option v-for="item in curricula">{{item.curriculumId}}</option>
|
<option v-for="item in curricula">{{item.curriculumId}}</option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div style="align-self:center;" class="inputBox">
|
<div style="align-self:center;" class="inputBox">
|
||||||
<button style="margin-top:25px;" @click="console.log(outputs);register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, ppData);">
|
<button style="margin-top:25px;" @click="console.log(curriculum);register(firstname, surname, birthday, password, mail, address, country, curriculum);">
|
||||||
{{i18n("login.guest.submit")}}
|
{{i18n("login.guest.submit")}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* TODO: On time of writing, the backend doesn't support these endpoints so it could be modified in the future.
|
* TODO: On time of writing, the backend doesn't support these endpoints so it could be modified in the future.
|
||||||
*/
|
*/
|
||||||
import {restGet, restPatch,restPatchInfo} from './restConsumer.js'
|
import {restGet, restPatch} from './restConsumer.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a new register requests that can be recovered by the registering service
|
* create a new register requests that can be recovered by the registering service
|
||||||
@ -41,5 +41,5 @@ export async function getAllRegisters(){
|
|||||||
* Change the state of a requests.
|
* Change the state of a requests.
|
||||||
*/
|
*/
|
||||||
export async function validateRegister(id, state){
|
export async function validateRegister(id, state){
|
||||||
return restPatch("/request/register/" + id, state);
|
return restPatch("/request/register/" + id, {state: state});
|
||||||
}
|
}
|
||||||
|
@ -28,15 +28,14 @@ export function disconnect(){
|
|||||||
*/
|
*/
|
||||||
export async function register(firstname, lastname, birthDate, password, email, address, country, curriculumId, imageId){
|
export async function register(firstname, lastname, birthDate, password, email, address, country, curriculumId, imageId){
|
||||||
return restPost("/register", {
|
return restPost("/register", {
|
||||||
firstName: firstname,
|
firstname: firstname,
|
||||||
lastName: lastname,
|
lastname: lastname,
|
||||||
birthDate: birthDate,
|
birthDate: birthDate,
|
||||||
password: password,
|
password: password,
|
||||||
email: email,
|
email: email,
|
||||||
address: address,
|
address: address,
|
||||||
country: country,
|
country: country,
|
||||||
curriculumId: curriculumId,
|
curriculumId: curriculumId
|
||||||
profilePictureUrl: imageId,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ export async function restPost(endPoint, data) {
|
|||||||
return await _rest(endPoint, {method: "POST", credentials: 'include', body: JSON.stringify(data)});
|
return await _rest(endPoint, {method: "POST", credentials: 'include', body: JSON.stringify(data)});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function restPostFile(endPoint, file){
|
export async function restPostFile(endPoint, file){
|
||||||
let headers = new Headers();
|
let headers = new Headers();
|
||||||
return await _rest(endPoint, {method: "POST", credentials: 'include', body: file, headers: headers });
|
return await _rest(endPoint, {method: "POST", credentials: 'include', body: file, headers: headers });
|
||||||
@ -25,10 +24,6 @@ export async function restPatch(endPoint, data) {
|
|||||||
return await _rest(endPoint, {method: "PATCH", credentials: 'include', body: JSON.stringify(data)});
|
return await _rest(endPoint, {method: "PATCH", credentials: 'include', body: JSON.stringify(data)});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function restPatchInfo(endPoint, data){
|
|
||||||
return await _rest(endPoint, {method: "PATCH", credentials: 'include', body: data});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* backbone for the request made by the frontend
|
* backbone for the request made by the frontend
|
||||||
*
|
*
|
||||||
|