Skip to content

Commit ac999b2

Browse files
committed
Fix user page
1 parent 2c98298 commit ac999b2

File tree

2 files changed

+4
-71
lines changed

2 files changed

+4
-71
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,11 @@ public String showUserInfo(Model model, @PathVariable long id, HttpServletReques
9999
Principal principal = request.getUserPrincipal();
100100

101101
if(principal != null) {
102-
String userName = principal.getName();
103-
User user = userService.findByFirstName(userName);
102+
User user = userService.findById(id).get();
104103
long userId;
105-
userId = user.getId();
104+
userId = (long) model.getAttribute("userId");
106105

107-
if (userId != id) {
106+
if (model.getAttribute("admin").equals(false) && userId != id) {
108107
return "accessDenied";
109108
}
110109

@@ -121,7 +120,7 @@ public String showUserInfo(Model model, @PathVariable long id, HttpServletReques
121120
model.addAttribute("coursesBoughtTimes", coursesBoughtTimes);
122121
}
123122

124-
model.addAttribute("orders", orderPService.findByUserId(userId));
123+
model.addAttribute("orders", orderPService.findByUserId(id));
125124
model.addAttribute("user", user);
126125
}
127126
return "myAccount";

backend/target/classes/templates/product.html

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

0 commit comments

Comments
 (0)