Merge branch 'master' into tonitch/front/serviceInscription
This commit is contained in:
		| @ -53,5 +53,5 @@ jobs: | ||||
|         scp -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key -r * ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:api/ | ||||
|     - name: restarting the backend  | ||||
|       run: | | ||||
|         ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd api/backend && docker build -t clyde/backend . && docker rm clyde_backend_prod -f || true && docker run --rm -d --name clyde_backend_prod -p 4000:8080 clyde/backend && docker image prune -f" | ||||
|         ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd api/backend && docker build -t clyde/backend . && docker rm clyde_backend_prod -f || true && docker run --rm -d -u $(id -u clyde):$(id -g clyde) -v /var/run/postgresql:/var/run/postgresql --name clyde_backend_prod -p 4000:8080 clyde/backend && docker image prune -f' | ||||
|     - run: echo "The backend has been deployed. running at https://clyde.herisson.ovh/api" | ||||
|  | ||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -6,3 +6,4 @@ build | ||||
|  | ||||
| .project | ||||
| .settings | ||||
| .idea/ | ||||
|  | ||||
| @ -20,6 +20,8 @@ dependencies { | ||||
| 	implementation("org.springframework.boot:spring-boot-starter-data-jpa") | ||||
| 	implementation("org.springframework.boot:spring-boot-starter-mail") | ||||
| 	implementation("org.springframework.boot:spring-boot-starter-web") | ||||
| 	implementation("org.springframework.boot:spring-boot-starter-data-jpa") | ||||
| 	implementation("com.kohlschutter.junixsocket:junixsocket-core:2.9.0") | ||||
| 	// implementation("org.springframework.session:spring-session-jdbc") | ||||
| 	developmentOnly("org.springframework.boot:spring-boot-devtools") | ||||
| 	developmentOnly("org.springframework.boot:spring-boot-docker-compose") | ||||
|  | ||||
| @ -0,0 +1,44 @@ | ||||
| package ovh.herisson.Clyde.EndPoints; | ||||
|  | ||||
|  | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.http.HttpStatusCode; | ||||
| import org.springframework.http.ResponseEntity; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import ovh.herisson.Clyde.Repositories.UserRepository; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
|  | ||||
|  | ||||
| @RestController | ||||
| @CrossOrigin(origins = "http://localhost:5173") | ||||
| public class UserController { | ||||
|  | ||||
|     private final UserRepository userRepo; | ||||
|  | ||||
|     public UserController(UserRepository userRepo){ | ||||
|         this.userRepo = userRepo; | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/user") | ||||
|     public ResponseEntity<User> getUsers(@RequestHeader("Authorization") String token){ | ||||
|         //TODO | ||||
|         // Get the token thru the data base | ||||
|         // tokenRepo.findToken(token) => User userFromToken | ||||
|         // si role != secretary => return error : ResponseEntity<User>(null, HttpStatus.UNAUTHORIZED) | ||||
|         return new ResponseEntity<User>(/**userRepo.findById(userFromToken.id),**/ HttpStatus.OK); | ||||
|     } | ||||
|  | ||||
|     @PostMapping("/user") | ||||
|     public ResponseEntity<String> postUser(@RequestBody User user){ | ||||
|         userRepo.save(user); | ||||
|         return new ResponseEntity<String>(String.format("Account created with ID:%s",user.getRegNo()),HttpStatus.CREATED); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/users") | ||||
|     public Iterable<User> getAllUsers(){//TODO ne l'accepter que si c'est le secrétariat | ||||
|         return userRepo.findAll(); | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -29,7 +29,7 @@ public class JdbcConfig { | ||||
| 	public DataSource psqlSourceProd(){ | ||||
| 		DriverManagerDataSource source = new DriverManagerDataSource(); | ||||
| 		source.setDriverClassName("org.postgresql.Driver"); | ||||
| 		source.setUrl("jdbc:postgresql://localhost:5432/clyde"); | ||||
| 		source.setUrl("jdbc:postgresql:clyde?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"); | ||||
| 		source.setUsername("clyde"); | ||||
|  | ||||
| 		return source; | ||||
|  | ||||
| @ -0,0 +1,16 @@ | ||||
| package ovh.herisson.Clyde.Repositories; | ||||
|  | ||||
| import org.springframework.data.jpa.repository.Query; | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import ovh.herisson.Clyde.Tables.User; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| public interface UserRepository extends CrudRepository<User, Long> { | ||||
|  | ||||
|     User findById(long id); | ||||
|  | ||||
|     /** | ||||
|     @Query(value = "select a.* from Users a ",nativeQuery = true) | ||||
|     Iterable<User> findAllUsers();**/ | ||||
| } | ||||
							
								
								
									
										52
									
								
								backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,52 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.GeneratedValue; | ||||
| import jakarta.persistence.GenerationType; | ||||
| import jakarta.persistence.Id; | ||||
|  | ||||
| @Entity | ||||
| public class Course { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int courseID; | ||||
|     private int credits; | ||||
|     private String title; | ||||
|     private String faculty; | ||||
|  | ||||
|     public Course(int credits, String title, String faculty){ | ||||
|         this.credits = credits; | ||||
|         this.title = title; | ||||
|         this.faculty = faculty; | ||||
|     } | ||||
|  | ||||
|     public Course() {} | ||||
|  | ||||
|     public int getCourseID() { | ||||
|         return courseID; | ||||
|     } | ||||
|  | ||||
|     public int getCredits() { | ||||
|         return credits; | ||||
|     } | ||||
|  | ||||
|     public void setCredits(int credits){ | ||||
|         this.credits = credits; | ||||
|     } | ||||
|  | ||||
|     public String getFaculty() { | ||||
|         return faculty; | ||||
|     } | ||||
|  | ||||
|     public void setFaculty(String faculty){ | ||||
|         this.faculty = faculty; | ||||
|     } | ||||
|  | ||||
|     public String getTitle() { | ||||
|         return title; | ||||
|     } | ||||
|  | ||||
|     public void setTitle(String title){ | ||||
|         this.title = title; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										43
									
								
								backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.GeneratedValue; | ||||
| import jakarta.persistence.GenerationType; | ||||
| import jakarta.persistence.Id; | ||||
|  | ||||
| @Entity | ||||
| public class Cursus { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int cursusId; | ||||
|     private int year; | ||||
|     private String option; | ||||
|  | ||||
|     public Cursus(int year, String option){ | ||||
|         this.year = year; | ||||
|         this.option = option; | ||||
|     } | ||||
|  | ||||
|     public Cursus() {} | ||||
|  | ||||
|     public int getCursusId(){ | ||||
|         return this.cursusId; | ||||
|     } | ||||
|  | ||||
|     public int getYear(){ | ||||
|         return this.year; | ||||
|     } | ||||
|  | ||||
|     public void setYear(int year){ | ||||
|         this.year = year; | ||||
|     } | ||||
|  | ||||
|     public String getOption(){ | ||||
|         return this.option; | ||||
|     } | ||||
|  | ||||
|     public void setOption(String option){ | ||||
|         this.option = option; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,43 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
|  | ||||
| @Entity | ||||
| public class CursusCourse { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int id; | ||||
|  | ||||
|     @JoinColumn(name = "Cursus") | ||||
|     private int cursusId; | ||||
|  | ||||
|     @JoinColumn(name = "Course") | ||||
|     private int courseId; | ||||
|  | ||||
|     public CursusCourse(int cursusId, int courseId){ | ||||
|         this.cursusId = cursusId; | ||||
|         this.courseId = courseId; | ||||
|     } | ||||
|  | ||||
|     public CursusCourse() {} | ||||
|  | ||||
|     public int getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public int getCourseId() { | ||||
|         return courseId; | ||||
|     } | ||||
|  | ||||
|     public void setCourseId(int courseId){ | ||||
|         this.courseId = courseId; | ||||
|     } | ||||
|  | ||||
|     public int getCursusId() { | ||||
|         return cursusId; | ||||
|     } | ||||
|  | ||||
|     public void setCursusId(int cursusId) { | ||||
|         this.cursusId = cursusId; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,8 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| public enum Role { | ||||
|     Teacher, | ||||
|     Student, | ||||
|     Admin, | ||||
|     Secretary; | ||||
| } | ||||
| @ -0,0 +1,41 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
|  | ||||
| @Entity | ||||
| public class Secretary { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int id; | ||||
|  | ||||
|     @JoinColumn(name = "Users") | ||||
|     private int regNo; | ||||
|     private String faculty; | ||||
|  | ||||
|     public Secretary(int regNo, String faculty){ | ||||
|         this.regNo = regNo; | ||||
|         this.faculty = faculty; | ||||
|     } | ||||
|  | ||||
|     public Secretary() {} | ||||
|  | ||||
|     public int getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public int getRegNo() { | ||||
|         return regNo; | ||||
|     } | ||||
|  | ||||
|     public void setRegNo(int regNo) { | ||||
|         this.regNo = regNo; | ||||
|     } | ||||
|  | ||||
|     public String getFaculty() { | ||||
|         return faculty; | ||||
|     } | ||||
|  | ||||
|     public void setFaculty(String faculty) { | ||||
|         this.faculty = faculty; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,55 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
|  | ||||
| @Entity | ||||
| public class TeacherGivenCourse { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int id; | ||||
|  | ||||
|     @JoinColumn(name = "Users") | ||||
|     private int regNo; | ||||
|  | ||||
|     @JoinColumn(name = "Course") | ||||
|     private int courseId; | ||||
|  | ||||
|     //This flag helps make the difference between an assistant or a Teacher (who owns the course) | ||||
|     private boolean owned; | ||||
|  | ||||
|     public TeacherGivenCourse(int regNo, int courseId, boolean owned){ | ||||
|         this.regNo = regNo; | ||||
|         this.courseId = courseId; | ||||
|         this.owned = owned; | ||||
|     } | ||||
|  | ||||
|     public TeacherGivenCourse() {} | ||||
|  | ||||
|     public int getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public int getRegNo() { | ||||
|         return regNo; | ||||
|     } | ||||
|  | ||||
|     public void setRegNo(int regNo) { | ||||
|         this.regNo = regNo; | ||||
|     } | ||||
|  | ||||
|     public int getCourseId() { | ||||
|         return courseId; | ||||
|     } | ||||
|  | ||||
|     public void setCourseId(int courseId) { | ||||
|         this.courseId = courseId; | ||||
|     } | ||||
|  | ||||
|     public boolean isOwned() { | ||||
|         return owned; | ||||
|     } | ||||
|  | ||||
|     public void setOwned(boolean owned) { | ||||
|         this.owned = owned; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										40
									
								
								backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
|  | ||||
| @Entity | ||||
| public class Token { | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     @Id | ||||
|     private int id; | ||||
|  | ||||
|     @JoinColumn(name ="Users") | ||||
|     private int regNo; | ||||
|     private String token; | ||||
|  | ||||
|     public Token(int regNo, String token){ | ||||
|         this.regNo = regNo; | ||||
|         this.token = token; | ||||
|     } | ||||
|  | ||||
|     public Token(){} | ||||
|     public int getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public int getRegNo() { | ||||
|         return regNo; | ||||
|     } | ||||
|  | ||||
|     public void setRegNo(int regNo) { | ||||
|         this.regNo = regNo; | ||||
|     } | ||||
|  | ||||
|     public String getToken(){ | ||||
|         return token; | ||||
|     } | ||||
|  | ||||
|     public void setToken(String data) { | ||||
|         this.token = data; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										103
									
								
								backend/src/main/java/ovh/herisson/Clyde/Tables/User.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								backend/src/main/java/ovh/herisson/Clyde/Tables/User.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,103 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| //Classe représentant un utilisateur l'attribut password demande surement un peu de rafinement niveau sécurité | ||||
| //et l'attribut tokenApi doit encore être ajouté vu qu'il faut en discuter | ||||
|  | ||||
| @Entity | ||||
| //Je rajoute un s au nom de la table pour éviter les conflits avec les mots réservés | ||||
| @Table(name = "Users") | ||||
| public class User { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int regNo; | ||||
|     private String lastName; | ||||
|     private String firstName; | ||||
|     private String email; | ||||
|     private String address; | ||||
|     private String country; | ||||
|     private Date birthDate; | ||||
|     private ovh.herisson.Clyde.Tables.Role role; | ||||
|     private String password; | ||||
|     public User(String lastName, String firstName, String email, String address, String country, Date birthDate, Role role, String password){ | ||||
|         this.lastName = lastName; | ||||
|         this.firstName = firstName; | ||||
|         this.email = email; | ||||
|         this.address = address; | ||||
|         this.country = country; | ||||
|         this.birthDate = birthDate; | ||||
|         this.role = role; | ||||
|         this.password = password; | ||||
|     } | ||||
|  | ||||
|     public User() {} | ||||
|  | ||||
|     public int getRegNo(){ | ||||
|         return this.regNo; | ||||
|     } | ||||
|     public String getLastName() { | ||||
|         return lastName; | ||||
|     } | ||||
|  | ||||
|     public void setLastName(String lastName) { | ||||
|         this.lastName = lastName; | ||||
|     } | ||||
|  | ||||
|     public String getFirstName() { | ||||
|         return firstName; | ||||
|     } | ||||
|  | ||||
|     public void setFirstName(String firstName) { | ||||
|         this.firstName = firstName; | ||||
|     } | ||||
|  | ||||
|     public String getEmail() { | ||||
|         return email; | ||||
|     } | ||||
|  | ||||
|     public void setEmail(String email) { | ||||
|         this.email = email; | ||||
|     } | ||||
|  | ||||
|     public String getAddress() { | ||||
|         return address; | ||||
|     } | ||||
|  | ||||
|     public void setAddress(String adress) { | ||||
|         this.address = adress; | ||||
|     } | ||||
|  | ||||
|     public String getCountry() { | ||||
|         return country; | ||||
|     } | ||||
|  | ||||
|     public void setCountry(String country) { | ||||
|         this.country = country; | ||||
|     } | ||||
|  | ||||
|     public Date getBirthDate() { | ||||
|         return birthDate; | ||||
|     } | ||||
|  | ||||
|     public void setBirthDate(Date birthDate) { | ||||
|         this.birthDate = birthDate; | ||||
|     } | ||||
|  | ||||
|     public ovh.herisson.Clyde.Tables.Role getRole() { | ||||
|         return role; | ||||
|     } | ||||
|  | ||||
|     public void setRole(ovh.herisson.Clyde.Tables.Role role) { | ||||
|         this.role = role; | ||||
|     } | ||||
|     public String getPassword(){ | ||||
|         return password; | ||||
|     } | ||||
|  | ||||
|     public void setPassword(String password) { | ||||
|         this.password = password; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,42 @@ | ||||
| package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
|  | ||||
| @Entity | ||||
| public class UserCursus { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int id; | ||||
|     @JoinColumn(name = "Users") | ||||
|     private int regNo; | ||||
|  | ||||
|     @JoinColumn(name = "Cursus") | ||||
|     private int cursusId; | ||||
|  | ||||
|     public UserCursus(int regNo, int cursusId){ | ||||
|         this.regNo = regNo; | ||||
|         this.cursusId = cursusId; | ||||
|     } | ||||
|  | ||||
|     public UserCursus() {} | ||||
|  | ||||
|     public int getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public int getRegNo() { | ||||
|         return regNo; | ||||
|     } | ||||
|  | ||||
|     public void setRegNo(int regNo) { | ||||
|         this.regNo = regNo; | ||||
|     } | ||||
|  | ||||
|     public int getCursusId() { | ||||
|         return cursusId; | ||||
|     } | ||||
|  | ||||
|     public void setCursusId(int cursusId) { | ||||
|         this.cursusId = cursusId; | ||||
|     } | ||||
| } | ||||
| @ -1 +1,2 @@ | ||||
| spring.jpa.hibernate.ddl-auto=create-drop | ||||
| spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect | ||||
|  | ||||
| @ -24,7 +24,7 @@ let langs; | ||||
|  * | ||||
|  * @return :string The translated text | ||||
|  */ | ||||
| function i18n(key, options) { | ||||
| export default function i18n(key, options) { | ||||
| 	let ret = langs[key]; | ||||
| 	if(options != null){ | ||||
| 		for (let key in options) { | ||||
| @ -34,14 +34,6 @@ function i18n(key, options) { | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| async function reloadLang(){ | ||||
| 	langs = await loadLangs(); | ||||
| } | ||||
| reloadLang(); | ||||
|  | ||||
| export default i18n; | ||||
|  | ||||
|  | ||||
| // | ||||
| // Those functions are utility functions use by previous exported functions. | ||||
| // | ||||
| @ -51,11 +43,11 @@ export default i18n; | ||||
|  * @param select the language to load. could be null to fetch the cookies for an answer | ||||
|  * if nothing is found. default to EN.txt | ||||
|  */ | ||||
| async function loadLangs(lang){ | ||||
| export async function loadLangs(lang){ | ||||
| 	lang = lang != null ? lang : getCookie("lang"); | ||||
| 	lang = lang != "" ? lang : default_lang; | ||||
|  | ||||
| 	const filename = "./i18n/" + lang.toUpperCase() + ".txt"; | ||||
| 	const filename = "/i18n/" + lang.toUpperCase() + ".txt"; | ||||
| 	const content = await (await fetch(filename)).text(); | ||||
| 	const lines = content.split("\n"); | ||||
|  | ||||
| @ -66,5 +58,6 @@ async function loadLangs(lang){ | ||||
| 			filteredLines[line.substr(0, split)] = line.substr(split+1, line.length); | ||||
| 		}; | ||||
| 	} | ||||
| 	return filteredLines; | ||||
| 	langs = filteredLines; | ||||
| } | ||||
| await loadLangs(); | ||||
|  | ||||
| @ -8,6 +8,15 @@ export default defineConfig({ | ||||
|   plugins: [ | ||||
|     vue(), | ||||
|   ], | ||||
|   build: { | ||||
|  	rollupOptions:{ | ||||
| 		input:{ | ||||
| 			main: './index.html', | ||||
| 			login: './login/index.html' | ||||
| 		} | ||||
|    | ||||
|   	} | ||||
|   }, | ||||
|   resolve: { | ||||
|     alias: { | ||||
|       '@': fileURLToPath(new URL('./src', import.meta.url)) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user