File tree Expand file tree Collapse file tree
src/main/kotlin/fi/hsl/jore4/auth/audit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,18 +2,17 @@ package fi.hsl.jore4.auth.audit
22
33import org.slf4j.Logger
44import org.slf4j.LoggerFactory
5- import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
5+ import org.springframework.beans.factory.annotation.Autowired
66import org.springframework.stereotype.Service
77import org.springframework.transaction.annotation.Transactional
88
99/* *
1010 * Service for logging login events.
11- * Only enabled when JPA is available.
1211 */
1312@Service
14- @ConditionalOnBean(LoginAuditRepository ::class )
1513open class LoginAuditService (
16- private val loginAuditRepository : LoginAuditRepository
14+ @Autowired(required = false )
15+ private val loginAuditRepository : LoginAuditRepository ?
1716) {
1817 companion object {
1918 private val LOGGER : Logger = LoggerFactory .getLogger(LoginAuditService ::class .java)
@@ -27,6 +26,11 @@ open class LoginAuditService(
2726 userId : String ,
2827 userName : String?
2928 ) {
29+ if (loginAuditRepository == null ) {
30+ LOGGER .warn(" LoginAuditRepository is not available, cannot record login" )
31+ return
32+ }
33+
3034 try {
3135 val auditRecord =
3236 LoginAudit (
You can’t perform that action at this time.
0 commit comments