diff --git a/src/main/java/com/makersacademy/acebook/config/SecurityConfig.java b/src/main/java/com/makersacademy/acebook/config/SecurityConfig.java index 76682196..7eff1f12 100644 --- a/src/main/java/com/makersacademy/acebook/config/SecurityConfig.java +++ b/src/main/java/com/makersacademy/acebook/config/SecurityConfig.java @@ -34,7 +34,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .formLogin(formLogin -> formLogin .loginPage("/login") - .defaultSuccessUrl("/home", true) + .defaultSuccessUrl("/", true) .permitAll() ) .oauth2Login(oauth2Login -> @@ -43,7 +43,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .userInfoEndpoint(userInfoEndpoint -> userInfoEndpoint.userService(customOAuth2UserService) ) - .defaultSuccessUrl("/home", true) + .defaultSuccessUrl("/", true) ) .logout(logout -> logout diff --git a/src/main/java/com/makersacademy/acebook/controller/EventsController.java b/src/main/java/com/makersacademy/acebook/controller/EventsController.java index 67829ca9..5abefe19 100644 --- a/src/main/java/com/makersacademy/acebook/controller/EventsController.java +++ b/src/main/java/com/makersacademy/acebook/controller/EventsController.java @@ -88,6 +88,6 @@ public String userEvents(Model model, } model.addAttribute("events", events); model.addAttribute("event", new Event()); - return "events/users"; + return "events"; } } diff --git a/src/main/java/com/makersacademy/acebook/controller/HomeController.java b/src/main/java/com/makersacademy/acebook/controller/HomeController.java deleted file mode 100644 index d21b675a..00000000 --- a/src/main/java/com/makersacademy/acebook/controller/HomeController.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.makersacademy.acebook.controller; - -import com.makersacademy.acebook.model.Event; -import com.makersacademy.acebook.model.User; -import com.makersacademy.acebook.repository.EventRepository; -import com.makersacademy.acebook.repository.UserRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.oauth2.core.user.OAuth2User; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.view.RedirectView; - -@Controller -public class HomeController { - - @Autowired - EventRepository eventRepository; - - @RequestMapping(value = "/") - public RedirectView index() { - return new RedirectView("/events"); - } - - @GetMapping("/home") - public String home(Model model, @AuthenticationPrincipal Object principal) { - String username; - - if (principal instanceof UserDetails) { - username = ((UserDetails) principal).getUsername(); - } else if (principal instanceof OAuth2User) { - username = ((OAuth2User) principal).getAttribute("name"); - } else { - username = "User"; - } - - model.addAttribute("name", username); - - Iterable events = eventRepository.findAll(); - model.addAttribute("events", events); - model.addAttribute("event", new Event()); - return "home"; - } - -} diff --git a/src/main/java/com/makersacademy/acebook/controller/ThirdPartyEventController.java b/src/main/java/com/makersacademy/acebook/controller/ThirdPartyEventController.java index 3d021d06..08313e82 100644 --- a/src/main/java/com/makersacademy/acebook/controller/ThirdPartyEventController.java +++ b/src/main/java/com/makersacademy/acebook/controller/ThirdPartyEventController.java @@ -17,7 +17,7 @@ public class ThirdPartyEventController { @Autowired private ThirdPartyEventService thirdPartyEventService; - @GetMapping("/events") + @GetMapping("/events/third-party-events") public String searchEvent(Model model) { try { List thirdPartyEvents = thirdPartyEventService.searchEvent().get(); @@ -26,6 +26,6 @@ public String searchEvent(Model model) { e.printStackTrace(); // model.addAttribute("thirdPartyEvents", List.of()); } - return "index"; + return "events/third-party-events"; } } diff --git a/src/main/java/com/makersacademy/acebook/controller/UserController.java b/src/main/java/com/makersacademy/acebook/controller/UserController.java index d8f6fe4c..9036128b 100644 --- a/src/main/java/com/makersacademy/acebook/controller/UserController.java +++ b/src/main/java/com/makersacademy/acebook/controller/UserController.java @@ -16,10 +16,10 @@ public class UserController { @Autowired private UserRepository userRepository; - @GetMapping("/") - public String listUsers(Model model) { - List users = userRepository.findAll(); - model.addAttribute("users", users); - return "users"; - } +// @GetMapping("/") +// public String listUsers(Model model) { +// List users = userRepository.findAll(); +// model.addAttribute("users", users); +// return "users"; +// } } diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 649e0baa..c038ee2a 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,15 +1,30 @@ +#spring.datasource.url=jdbc:postgresql://socialites.czyiqc0ga4tn.us-east-1.rds.amazonaws.com:5432/socialites_springboot_development +#spring.datasource.username=${DB_USERNAME} +#spring.datasource.password=${DB_PASSWORD} +#flyway.baseline-on-migrate=true +#spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false +#spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect +#spring.security.oauth2.client.registration.google.client-id=${GOOGLE_ID} +#spring.security.oauth2.client.registration.google.client-secret=${GOOGLE_SECRET} +##spring.security.oauth2.client.registration.google.scope=profile, email +##spring.security.oauth2.client.registration.google.redirect-uri="http://qxvdpmwpb4.us-east-1.awsapprunner.com/login/oauth2/code/google" +##spring.security.oauth2.client.registration.google.authorization-grant-type=authorization_code +##spring.security.oauth2.client.registration.google.client-name=Google + spring.datasource.url=jdbc:postgresql://socialites01.czyiqc0ga4tn.us-east-1.rds.amazonaws.com:5432/socialites_springboot_development_01 spring.datasource.username=${DB_USERNAME} spring.datasource.password=${DB_PASSWORD} flyway.baseline-on-migrate=true spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect -# Only one set of Google OAuth2 registration properties should be present spring.security.oauth2.client.registration.google.client-id=${GOOGLE_ID} spring.security.oauth2.client.registration.google.client-secret=${GOOGLE_SECRET} spring.security.oauth2.client.registration.google.scope=profile, email spring.security.oauth2.client.registration.google.redirect-uri={baseUrl}/login/oauth2/code/google spring.security.oauth2.client.registration.google.authorization-grant-type=authorization_code spring.security.oauth2.client.registration.google.client-name=Google +spring.security.oauth2.client.registration.google.redirect-uri=http://qxvdpmwpb4.us-east-1.awsapprunner.com/login/oauth2/code/google +spring.security.oauth2.client.registration.google.authorization-grant-type=authorization_code +spring.security.oauth2.client.registration.google.client-name=Google diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/events/events.html similarity index 69% rename from src/main/resources/templates/home.html rename to src/main/resources/templates/events/events.html index 02b72e8b..b23d5eb1 100644 --- a/src/main/resources/templates/home.html +++ b/src/main/resources/templates/events/events.html @@ -1,12 +1,12 @@ - Home + User-Hosted Events - +
@@ -15,12 +15,19 @@

Welcome, User!

- +
+ + + + +
diff --git a/src/main/resources/templates/events/index.html b/src/main/resources/templates/events/third-party-events.html similarity index 100% rename from src/main/resources/templates/events/index.html rename to src/main/resources/templates/events/third-party-events.html diff --git a/src/main/resources/templates/events/users.html b/src/main/resources/templates/events/users.html deleted file mode 100644 index 896bd6f9..00000000 --- a/src/main/resources/templates/events/users.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - User-Hosted Events - - - - - - -
- -

Welcome, User!

- -
- - - - -
-
    -
  • -
    Title:
    -
    Description:
    -
    Date:
    -
    Time:
    -
  • -
- - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/fragments/nav.html b/src/main/resources/templates/fragments/nav.html index 0ed4565e..37bf19af 100644 --- a/src/main/resources/templates/fragments/nav.html +++ b/src/main/resources/templates/fragments/nav.html @@ -16,9 +16,6 @@
- > +