Skip to content

Commit

Permalink
Merge pull request #10 from The-Socialites/Fixing-routing
Browse files Browse the repository at this point in the history
fixed routing
  • Loading branch information
Umi007 authored Jun 24, 2024
2 parents 2028945 + ae8b7ef commit 1392496
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.formLogin(formLogin ->
formLogin
.loginPage("/login")
.defaultSuccessUrl("/home", true)
.defaultSuccessUrl("/", true)
.permitAll()
)
.oauth2Login(oauth2Login ->
Expand All @@ -43,7 +43,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.userInfoEndpoint(userInfoEndpoint ->
userInfoEndpoint.userService(customOAuth2UserService)
)
.defaultSuccessUrl("/home", true)
.defaultSuccessUrl("/", true)
)
.logout(logout ->
logout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ public String userEvents(Model model,
}
model.addAttribute("events", events);
model.addAttribute("event", new Event());
return "events/users";
return "events";
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<ThirdPartyEvent> thirdPartyEvents = thirdPartyEventService.searchEvent().get();
Expand All @@ -26,6 +26,6 @@ public String searchEvent(Model model) {
e.printStackTrace();
// model.addAttribute("thirdPartyEvents", List.of());
}
return "index";
return "events/third-party-events";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public class UserController {
@Autowired
private UserRepository userRepository;

@GetMapping("/")
public String listUsers(Model model) {
List<User> users = userRepository.findAll();
model.addAttribute("users", users);
return "users";
}
// @GetMapping("/")
// public String listUsers(Model model) {
// List<User> users = userRepository.findAll();
// model.addAttribute("users", users);
// return "users";
// }
}
17 changes: 16 additions & 1 deletion src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -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


Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Home</title>
<title>User-Hosted Events</title>
<link rel="stylesheet" th:href="@{/css/nav.css}">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">

</head>

<body>
<div th:replace="fragments/nav :: navbar"></div>

Expand All @@ -15,12 +15,19 @@ <h1>Welcome, <span th:text="${name}">User</span>!</h1>
<form th:action="@{/logout}" method="post">
<button type="submit">Logout</button>
</form>

<form action="/" method="get">
<input type="date" name="minScheduledDate" placeholder="Start Date">
<input type="date" name="maxScheduledDate" placeholder="End Date">
<button type="submit">Search</button>
<!-- <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>-->
</form>
<ul>
<li th:each="event : ${events}">
<a th:href="@{/events/details/{eventId}(eventId=${event.id})}">
<div><strong>Title:</strong> <span th:text="${event.title}"></span></div>
<div><strong>Description:</strong> <span th:text="${event.description}"></span></div>
<div><strong>Date:</strong> <span th:text="${#dates.format(event.scheduledDate, 'yyyy-MM-dd')}"></span></div>
<div><strong>Time:</strong> <span th:text="${event.scheduledStartTime}"></span></div>
</a>
</li>
</ul>
Expand Down
37 changes: 0 additions & 37 deletions src/main/resources/templates/events/users.html

This file was deleted.

5 changes: 1 addition & 4 deletions src/main/resources/templates/fragments/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" th:href="@{/home}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" th:href="@{/login}">Log in</a>
</li>
Expand All @@ -29,7 +26,7 @@
<a class="nav-link" th:href="@{/events/new}">Create Events</a>
</li>
<li class="nav-item">
<a class="nav-link" th:href="@{/events}">Find Events</a>
<a class="nav-link" th:href="@{/events/third-party-events}">Find Events</a>
</li>
</ul>
<form class="d-flex">
Expand Down
32 changes: 0 additions & 32 deletions src/main/resources/templates/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/templates/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2>Sign Up</h2>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" th:field="*{email}" placeholder="Enter email" required>>
<input type="email" id="email" th:field="*{email}" placeholder="Enter email" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
Expand Down

0 comments on commit 1392496

Please sign in to comment.