Skip to content

Commit 2315ef7

Browse files
committed
fix two rest contollers
1 parent 055658e commit 2315ef7

File tree

4 files changed

+18
-118
lines changed

4 files changed

+18
-118
lines changed

backend/src/main/java/com/youdemy/controller/CourseRestController.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.net.URI;
66
import java.nio.file.Files;
7+
import java.security.Principal;
78
import java.sql.SQLException;
89
import java.util.ArrayList;
910
import java.util.Arrays;
@@ -12,6 +13,8 @@
1213
import java.util.Objects;
1314
import java.util.Optional;
1415

16+
import javax.servlet.http.HttpServletRequest;
17+
1518
import org.hibernate.engine.jdbc.BlobProxy;
1619
import org.springframework.beans.factory.annotation.Autowired;
1720
import org.springframework.http.HttpStatus;
@@ -83,7 +86,16 @@ public ResponseEntity<Course> getCourse(@PathVariable long id){
8386
// }
8487

8588
@PostMapping("/")
86-
public String postNewCourse(@RequestBody Course newCourse, Model model) throws IOException {
89+
public String postNewCourse(@RequestBody Course newCourse, Model model, HttpServletRequest request) throws IOException {
90+
91+
Principal principal = request.getUserPrincipal();
92+
93+
System.out.println("el email del usuario es tallllllllll "+ principal);
94+
95+
if (principal != null) {
96+
User user = userService.findByFirstName(principal.getName());
97+
System.out.println("el email del usuario es tallllllllll "+user.getEmail());
98+
}
8799

88100

89101
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

backend/src/main/java/com/youdemy/controller/api/CourseRestController.java

Lines changed: 0 additions & 116 deletions
This file was deleted.

backend/src/main/java/com/youdemy/model/User.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public User(String firstName, String lastName, String email, String encodedPassw
3636
public long getId() {
3737
return id;
3838
}
39+
40+
public String getEmail() {
41+
return email;
42+
}
3943

4044
public void setId(long id) {
4145
this.id = id;

backend/target/classes/META-INF/maven/com.youdemy/Youdemy/pom.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Generated by Maven Integration for Eclipse
2-
#Fri Mar 25 14:21:54 CET 2022
2+
#Sun Mar 27 11:42:50 CEST 2022
33
m2e.projectLocation=/Users/emi/Documents/URJC/Web Dev/webapp10/backend
44
m2e.projectName=Youdemy
55
groupId=com.youdemy

0 commit comments

Comments
 (0)