diff --git a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/config/WebSecurityConfig.kt b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/config/WebSecurityConfig.kt index 928c7e9..7f3e210 100644 --- a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/config/WebSecurityConfig.kt +++ b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/config/WebSecurityConfig.kt @@ -1,6 +1,7 @@ package dev.fyloz.trial.colorrecipesexplorer.config import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import dev.fyloz.trial.colorrecipesexplorer.exception.model.EntityNotFoundRestException import dev.fyloz.trial.colorrecipesexplorer.model.Employee import dev.fyloz.trial.colorrecipesexplorer.model.EmployeeLoginRequest import dev.fyloz.trial.colorrecipesexplorer.model.EmployeePermission @@ -53,7 +54,6 @@ import javax.servlet.http.HttpServletResponse @EnableGlobalMethodSecurity(prePostEnabled = true) @EnableConfigurationProperties(SecurityConfigurationProperties::class) class WebSecurityConfig( - val restAuthenticationEntryPoint: RestAuthenticationEntryPoint, val securityConfigurationProperties: SecurityConfigurationProperties, @Lazy val userDetailsService: EmployeeUserDetailsServiceImpl, @Lazy val employeeService: EmployeeServiceImpl, @@ -288,9 +288,11 @@ class JwtAuthorizationFilter( } } - private fun getAuthenticationToken(employeeId: String): UsernamePasswordAuthenticationToken { + private fun getAuthenticationToken(employeeId: String): UsernamePasswordAuthenticationToken? = try { val employeeDetails = userDetailsService.loadUserByEmployeeId(employeeId.toLong(), false) - return UsernamePasswordAuthenticationToken(employeeDetails.username, null, employeeDetails.authorities) + UsernamePasswordAuthenticationToken(employeeDetails.username, null, employeeDetails.authorities) + } catch (_: EntityNotFoundRestException) { + null } } diff --git a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/AccountService.kt b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/AccountService.kt index fbd32d0..366bc19 100644 --- a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/AccountService.kt +++ b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/AccountService.kt @@ -322,8 +322,7 @@ class EmployeeGroupServiceImpl( @Service class EmployeeUserDetailsServiceImpl( - val employeeService: EmployeeService, - val securityConfigurationProperties: SecurityConfigurationProperties + val employeeService: EmployeeService ) : EmployeeUserDetailsService { override fun loadUserByUsername(username: String): UserDetails {