je sais vraiment pas ce que j'ai ajouté mais amélioration jt'e jure
This commit is contained in:
		@ -80,7 +80,7 @@ public class ForumController {
 | 
				
			|||||||
	public ResponseEntity<Topic> postTopicToForum(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Topic data){
 | 
						public ResponseEntity<Topic> postTopicToForum(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Topic data){
 | 
				
			||||||
		User u = authServ.getUserFromToken(token);
 | 
							User u = authServ.getUserFromToken(token);
 | 
				
			||||||
		Forum f = forumRepo.findById(id).orElse(null);
 | 
							Forum f = forumRepo.findById(id).orElse(null);
 | 
				
			||||||
		if(!(f.getWriters().contains(u) || u.getRole() == Role.Admin)){
 | 
							if(!(f.getWriters().contains(u) || f.getCourse().getOwner().equals(u) || u.getRole() == Role.Admin)){
 | 
				
			||||||
			return new UnauthorizedResponse<>(null);
 | 
								return new UnauthorizedResponse<>(null);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		forumServ.createTopic(f, data);
 | 
							forumServ.createTopic(f, data);
 | 
				
			||||||
 | 
				
			|||||||
@ -28,10 +28,11 @@ public class Course {
 | 
				
			|||||||
    private User owner;
 | 
					    private User owner;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//// Extension Messagerie /////
 | 
						//// Extension Messagerie /////
 | 
				
			||||||
	@OneToMany(cascade = CascadeType.ALL)
 | 
						@OneToMany(mappedBy = "course", cascade = CascadeType.ALL)
 | 
				
			||||||
	private List<Forum> forums;
 | 
						private List<Forum> forums;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void addForum(Forum f){
 | 
						public void addForum(Forum f){
 | 
				
			||||||
 | 
							f.setCourse(this);
 | 
				
			||||||
		forums.add(f);
 | 
							forums.add(f);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	///////////////////////////////
 | 
						///////////////////////////////
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,8 @@ package ovh.herisson.Clyde.Tables.Msg;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.fasterxml.jackson.annotation.JsonIgnore;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import jakarta.persistence.*;
 | 
					import jakarta.persistence.*;
 | 
				
			||||||
import lombok.Data;
 | 
					import lombok.Data;
 | 
				
			||||||
import ovh.herisson.Clyde.Tables.Course;
 | 
					import ovh.herisson.Clyde.Tables.Course;
 | 
				
			||||||
@ -16,6 +18,7 @@ public class Forum {
 | 
				
			|||||||
	private int id;
 | 
						private int id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@ManyToOne
 | 
						@ManyToOne
 | 
				
			||||||
 | 
						@JsonIgnore
 | 
				
			||||||
	private Course course;
 | 
						private Course course;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private String name;
 | 
						private String name;
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,7 @@ window.onhashchange = function() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
const Logged = ref(isLogged());
 | 
					const Logged = ref(isLogged());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(Logged){
 | 
					if(Logged.value){
 | 
				
			||||||
	fetchNotifications();
 | 
						fetchNotifications();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,7 @@ import { fetchedPost, fetchPost, sendAnswer } from '@/rest/forum.js'
 | 
				
			|||||||
import { getSelf } from '@/rest/Users.js'
 | 
					import { getSelf } from '@/rest/Users.js'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const Role = (await getSelf()).role;
 | 
					const Role = (await getSelf()).role;
 | 
				
			||||||
const courses = Role === 'Admin' || Role === 'Secretary' ? await reactive(getCourses()) : await reactive(getUserActualCourses());
 | 
					const courses = Role === 'Admin' || Role === 'Secretary' || Role === 'Teacher' ? await reactive(getCourses(Role)) : await reactive(getUserActualCourses());
 | 
				
			||||||
const selectedCourse = ref();
 | 
					const selectedCourse = ref();
 | 
				
			||||||
const selectedForum = ref();
 | 
					const selectedForum = ref();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -8,8 +8,6 @@ import { restGet, restPost, restDelete, restPatch } from './restConsumer.js'
 | 
				
			|||||||
 * Create a new course
 | 
					 * Create a new course
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export async function createCourse(name, credits, owner){
 | 
					export async function createCourse(name, credits, owner){
 | 
				
			||||||
  console.log(owner);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
	return restPost("/course", {title: name, credits: credits, owner} )
 | 
						return restPost("/course", {title: name, credits: credits, owner} )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
import { ref } from 'vue'
 | 
					import { ref } from 'vue'
 | 
				
			||||||
import { restGet, restPost } from '@/rest/restConsumer.js'
 | 
					import { restGet, restPost } from '@/rest/restConsumer.js'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const notifications = ref({});
 | 
					export const notifications = ref([]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function fetchNotifications(){
 | 
					export function fetchNotifications(){
 | 
				
			||||||
	restGet("/notifications").then( e => notifications.value = e );
 | 
						restGet("/notifications").then( e => notifications.value = e );
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user