Skip to content

Commit

Permalink
Merge pull request #60 from phuuthanh2003/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
phuuthanh-dev authored Jun 12, 2024
2 parents 4b3653b + 0dbb196 commit 2ec93f4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package vn.webapp.backend.auction.config;

import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -63,15 +64,14 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.sessionManagement((session) -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authenticationProvider(authenticationProvider)
.httpBasic(Customizer.withDefaults())
.formLogin(formLogin ->
formLogin.loginPage("/api/v1/auth/login").permitAll()
)
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
.logout(logout ->
logout.logoutUrl("/api/v1/auth/logout")
.addLogoutHandler(logoutHandler)
.logoutSuccessHandler((request, response, authentication) -> SecurityContextHolder.clearContext())
);
).exceptionHandling(exceptionHandling -> exceptionHandling
.authenticationEntryPoint((request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED))
);;
return http.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ protected void doFilterInternal(
filterChain.doFilter(request, response);
} catch (ExpiredJwtException ex) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "JWT token is expired!");
} catch (Exception ex) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class RequestApproval {

@Column(name = "request_time", nullable = false)
private Timestamp requestTime;

@Column(name = "response_time")
private Timestamp responseTime;

Expand Down
11 changes: 0 additions & 11 deletions src/main/java/vn/webapp/backend/auction/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ public class User implements UserDetails {
@Column(name ="bank_account_name", nullable = false, length = 30)
private String bankAccountName;

// @ManyToOne
// @JoinColumn(name = "role_id")
// @EqualsAndHashCode.Exclude
// @ToString.Exclude
// private Role role;

@Enumerated(EnumType.STRING)
private Role role;
Expand All @@ -113,12 +108,6 @@ public class User implements UserDetails {
@JsonIgnore
private List<Jewelry> jewelries;

// @OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
// @EqualsAndHashCode.Exclude
// @ToString.Exclude
// @JsonIgnore
// private List<RequestApproval> requestApprovals;

public String getFullName() {
return firstName + " " + lastName;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ frontend.base-url=http://localhost:3000
spring.banner.location=banner.txt

# Config db
spring.datasource.url=jdbc:sqlserver://localhost:1433;encrypt=true;trustServerCertificate=true;databaseName=DB_AUCTION;
spring.datasource.url=jdbc:sqlserver://localhost:1433;encrypt=true;trustServerCertificate=true;collation=Latin1_General_100_CI_AS_SC_UTF8;databaseName=DB_AUCTION;
spring.datasource.username=sa
spring.datasource.password=12345
spring.datasource.password=Thanhth@nh1

# Config create table automatically
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=none

# Config email
spring.mail.host=smtp.gmail.com
Expand Down

0 comments on commit 2ec93f4

Please sign in to comment.