Compare commits

..

No commits in common. "cc89d7f5b7b2fea4fd28b0cba50bd917f45d6e65" and "684c3095eb7b4e9297d29a85f9648abe3e7d8d9b" have entirely different histories.

3 changed files with 7 additions and 26 deletions

1
.gitignore vendored
View File

@ -6,4 +6,3 @@ build
.project .project
.settings .settings
.idea/

View File

@ -1,9 +1,6 @@
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;
@ -19,26 +16,12 @@ 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> getAllUsers(){//TODO ne l'accepter que si c'est le secrétariat public Iterable<User> getUsers(){
return userRepo.findAll(); return userRepo.findAll();
} }
@PostMapping("/users")
public void postUser(@RequestBody User user ){
userRepo.save(user);
}
} }

View File

@ -2,7 +2,6 @@ package ovh.herisson.Clyde.Tables;
public enum Role { public enum Role {
Teacher, Teacher,
Student, Student;
Admin,
Secretary;
} }