Compare commits
	
		
			3 Commits
		
	
	
		
			684c3095eb
			...
			cc89d7f5b7
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| cc89d7f5b7 | |||
| 45bfe08c9a | |||
| 6c688dab59 | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -6,3 +6,4 @@ build
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
.project
 | 
					.project
 | 
				
			||||||
.settings
 | 
					.settings
 | 
				
			||||||
 | 
					.idea/
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,9 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.EndPoints;
 | 
					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 org.springframework.web.bind.annotation.*;
 | 
				
			||||||
import ovh.herisson.Clyde.Repositories.UserRepository;
 | 
					import ovh.herisson.Clyde.Repositories.UserRepository;
 | 
				
			||||||
import ovh.herisson.Clyde.Tables.User;
 | 
					import ovh.herisson.Clyde.Tables.User;
 | 
				
			||||||
@ -16,12 +19,26 @@ public class UserController {
 | 
				
			|||||||
        this.userRepo = 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")
 | 
					    @GetMapping("/users")
 | 
				
			||||||
    public Iterable<User> getUsers(){
 | 
					    public Iterable<User> getAllUsers(){//TODO ne l'accepter que si c'est le secrétariat
 | 
				
			||||||
        return userRepo.findAll();
 | 
					        return userRepo.findAll();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    @PostMapping("/users")
 | 
					
 | 
				
			||||||
    public void postUser(@RequestBody User user ){
 | 
					
 | 
				
			||||||
        userRepo.save(user);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,7 @@ package ovh.herisson.Clyde.Tables;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public enum Role {
 | 
					public enum Role {
 | 
				
			||||||
    Teacher,
 | 
					    Teacher,
 | 
				
			||||||
    Student;
 | 
					    Student,
 | 
				
			||||||
 | 
					    Admin,
 | 
				
			||||||
 | 
					    Secretary;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user