Changeset 763289e
- Timestamp:
- 10/31/22 23:42:15 (2 years ago)
- Branches:
- master
- Children:
- 044bd76
- Parents:
- 204464d
- Location:
- src/main
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/edu/gjoko/schedlr/config/AppSecurityConfig.java
r204464d r763289e 46 46 .disable() 47 47 .authorizeRequests() 48 .antMatchers("/login *").permitAll()48 .antMatchers("/login").permitAll() 49 49 .antMatchers("/register_customer").permitAll() 50 50 .antMatchers("/register_business").permitAll() 51 .antMatchers("/homepage").permitAll() 51 52 .antMatchers("/css/**").permitAll() 52 53 .antMatchers("/anonymous*").anonymous() … … 61 62 .loginPage("/login") 62 63 .loginProcessingUrl("/login") 63 .successHandler(authenticationSuccessHandler); 64 .successHandler(authenticationSuccessHandler) 65 .defaultSuccessUrl("/homepage"); 64 66 } 65 67 } -
src/main/java/edu/gjoko/schedlr/controllers/HomePageController.java
r204464d r763289e 4 4 import org.springframework.ui.Model; 5 5 import org.springframework.web.bind.annotation.GetMapping; 6 import org.springframework.web.bind.annotation.PostMapping; 7 import org.springframework.web.bind.annotation.RestController; 6 8 7 @ Controller9 @RestController(value = "/homepage") 8 10 public class HomePageController { 9 11 10 @GetMapping (value = "/homepage")12 @GetMapping 11 13 public String getHomePageTemplate(Model model) { 12 14 return "homepage"; 13 15 } 16 17 @PostMapping 18 public String postHomePageTemplate(Model model) { 19 return "homepage"; 20 } 14 21 } -
src/main/java/edu/gjoko/schedlr/controllers/LoginController.java
r204464d r763289e 1 1 package edu.gjoko.schedlr.controllers; 2 2 3 import edu.gjoko.schedlr.entity.Stakeholder; 3 4 import org.springframework.stereotype.Controller; 4 5 import org.springframework.ui.Model; 5 6 import org.springframework.web.bind.annotation.GetMapping; 7 import org.springframework.web.bind.annotation.ModelAttribute; 8 import org.springframework.web.bind.annotation.PostMapping; 6 9 7 10 @Controller 8 11 public class LoginController { 9 12 10 @GetMapping( value= "/login")13 @GetMapping(path = "/login") 11 14 public String getMapping(Model model) { 15 model.addAttribute("stakeholder", new Stakeholder()); 12 16 return "login"; 13 17 } 18 19 @PostMapping(path = "/login") 20 public String loginCustomer(@ModelAttribute Stakeholder customer, Model model) { 21 return "redirect:homepage"; 22 } 14 23 } -
src/main/java/edu/gjoko/schedlr/controllers/RegisterController.java
r204464d r763289e 20 20 } 21 21 22 @GetMapping( "/register_customer")22 @GetMapping(value ="/register_customer") 23 23 public String getCustomerRegisterPage(Model model) { 24 24 model.addAttribute("stakeholder", new Stakeholder()); … … 30 30 Stakeholder user = stakeholderService.saveStakeholder(customer); 31 31 model.addAttribute("user", user); 32 return " homepage";32 return "redirect:homepage"; 33 33 } 34 34 35 @GetMapping( "/register_business")35 @GetMapping(value = "/register_business") 36 36 public String getBusinessRegisterPage(Model model) { 37 37 return "register_business"; 38 38 } 39 39 40 @PostMapping( "/register_business")40 @PostMapping(value = "/register_business") 41 41 public String registerBusiness(Model model) { 42 42 return "register_business"; -
src/main/java/edu/gjoko/schedlr/services/PostgresUserDetailsService.java
r204464d r763289e 9 9 import org.springframework.security.core.userdetails.UserDetailsService; 10 10 import org.springframework.security.core.userdetails.UsernameNotFoundException; 11 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 11 12 import org.springframework.stereotype.Service; 12 13 … … 18 19 19 20 private final StakeholderRepository stakeholderRepository; 21 private final BCryptPasswordEncoder bCryptPasswordEncoder; 20 22 21 public PostgresUserDetailsService(StakeholderRepository stakeholderRepository) { 23 public PostgresUserDetailsService(StakeholderRepository stakeholderRepository, 24 BCryptPasswordEncoder bCryptPasswordEncoder) { 22 25 this.stakeholderRepository = stakeholderRepository; 26 this.bCryptPasswordEncoder = bCryptPasswordEncoder; 23 27 } 24 28 -
src/main/resources/templates/homepage.html
r204464d r763289e 3 3 <head> 4 4 <meta charset="UTF-8"> 5 <title> Title</title>5 <title>Homepage</title> 6 6 </head> 7 7 <body> -
src/main/resources/templates/login.html
r204464d r763289e 40 40 <div class="card"> 41 41 <div class="card-body py-5 px-md-5"> 42 <form >42 <form action="#" th:action="@{/login}" th:object="${stakeholder}" method="post"> 43 43 <!-- Email input --> 44 44 <div class="form-outline mb-4"> 45 <input type=" email" id="email" class="form-control"/>46 <label class="form-label" for=" email">Email address</label>45 <input type="text" id="username" class="form-control" required th:field="*{username}" /> 46 <label class="form-label" for="username">Username</label> 47 47 </div> 48 48 49 49 <!-- Password input --> 50 50 <div class="form-outline mb-4"> 51 <input type="password" id="password" class="form-control" />51 <input type="password" id="password" class="form-control" th:field="*{password}" /> 52 52 <label class="form-label" for="password">Password</label> 53 53 </div>
Note:
See TracChangeset
for help on using the changeset viewer.