Changeset 8bcd64c for src/main/java/edu/gjoko/schedlr/controllers
- Timestamp:
- 04/19/23 21:19:08 (19 months ago)
- Branches:
- master
- Children:
- 950fa0d
- Parents:
- 9050790
- Location:
- src/main/java/edu/gjoko/schedlr/controllers
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/edu/gjoko/schedlr/controllers/AdminController.java
r9050790 r8bcd64c 1 1 package edu.gjoko.schedlr.controllers; 2 2 3 import org.springframework.security.core.Authentication; 4 import org.springframework.security.core.context.SecurityContextHolder; 3 5 import org.springframework.stereotype.Controller; 4 6 import org.springframework.ui.Model; 5 7 import org.springframework.web.bind.annotation.GetMapping; 8 9 import javax.servlet.http.HttpServletRequest; 10 import java.security.Principal; 6 11 7 12 @Controller … … 9 14 10 15 @GetMapping(path = "/admin") 11 public String getAdminPageTemplate(Model model ) {16 public String getAdminPageTemplate(Model model, HttpServletRequest request) { 12 17 return "admin"; 13 18 } 19 20 @GetMapping(path = "/business_admin") 21 public String getBusinessAdminPageTemplate(Model model, HttpServletRequest request) { 22 Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); 23 String currentPrincipalName = authentication.getName(); 24 25 return "business_admin"; 26 } 27 28 14 29 } -
src/main/java/edu/gjoko/schedlr/controllers/HomePageController.java
r9050790 r8bcd64c 6 6 import org.springframework.web.bind.annotation.PostMapping; 7 7 8 import java.security.Principal;9 10 8 @Controller 11 9 public class HomePageController { 12 10 13 11 @GetMapping(path = "/homepage") 14 public String getHomePageTemplate(Model model, Principal principal) { 15 System.out.println(principal); 12 public String getHomePageTemplate(Model model) { 16 13 return "homepage"; 17 14 } -
src/main/java/edu/gjoko/schedlr/controllers/LoginController.java
r9050790 r8bcd64c 7 7 import org.springframework.web.bind.annotation.ModelAttribute; 8 8 import org.springframework.web.bind.annotation.PostMapping; 9 import org.springframework.web.bind.annotation.RequestParam; 10 11 import java.security.Principal; 9 12 10 13 @Controller … … 12 15 13 16 @GetMapping(path = "/login") 14 public String getMapping(@ModelAttribute Stakeholder customer, Model model) { 17 public String getMapping(@RequestParam(value = "error", required = false) String error, 18 @ModelAttribute Stakeholder customer, Model model) { 15 19 return "login"; 16 20 } -
src/main/java/edu/gjoko/schedlr/controllers/RegisterController.java
r9050790 r8bcd64c 28 28 @PostMapping(path = "/register_customer") 29 29 public String registerCustomer(@ModelAttribute Stakeholder customer, Model model) { 30 Stakeholder user =stakeholderService.saveStakeholder(customer);30 stakeholderService.saveStakeholder(customer); 31 31 return "redirect:login"; 32 32 } -
src/main/java/edu/gjoko/schedlr/controllers/rest/BusinessController.java
r9050790 r8bcd64c 4 4 import edu.gjoko.schedlr.services.BusinessService; 5 5 import lombok.AllArgsConstructor; 6 import org.springframework.security.core.Authentication; 7 import org.springframework.security.core.context.SecurityContextHolder; 6 8 import org.springframework.web.bind.annotation.*; 7 9 10 import javax.servlet.http.HttpServletRequest; 8 11 import java.util.List; 9 12 … … 29 32 businessService.updateBusinesses(businessList); 30 33 } 34 35 @GetMapping(path = "/me") 36 public Business getPersonalInfo(HttpServletRequest request) { 37 Long businessOwnerId = (long) request.getSession(true).getAttribute("stakeholderId"); 38 return businessService.findByOwner(businessOwnerId); 39 } 31 40 }
Note:
See TracChangeset
for help on using the changeset viewer.