Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit a7ee834

Browse files
authored
Merge pull request #59 from Zenfulcode/patch-password-validation
Patch password validation
2 parents f1dd4b0 + 486422e commit a7ee834

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/main/java/com/zenfulcode/commercify/commercify/config/SecurityConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
3636
"/api/v1/auth/**",
3737
"/api/v1/products/active",
3838
"/api/v1/products/{id}").permitAll()
39-
.requestMatchers("/admin/**").hasRole("ADMIN")
4039
.anyRequest().authenticated()
4140
)
4241
.sessionManagement(smc -> smc.sessionCreationPolicy(SessionCreationPolicy.STATELESS))

src/main/java/com/zenfulcode/commercify/commercify/service/AuthenticationService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ public UserDTO authenticate(LoginUserRequest login) {
8888
)
8989
);
9090

91-
return userRepository.findByEmail(login.email())
92-
.map(mapper)
93-
.orElseThrow();
91+
UserEntity user = userRepository.findByEmail(login.email()).orElseThrow();
92+
93+
if (passwordEncoder.matches(login.password(), user.getPassword()))
94+
return null;
95+
96+
return mapper.apply(user);
9497
}
9598

9699
@Transactional(readOnly = true)

0 commit comments

Comments
 (0)