Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package fi.hsl.jore4.auth.audit

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository

/**
* Repository for login records.
*/
@Repository
@ConditionalOnProperty(prefix = "session", name = ["enabled"], havingValue = "true")
interface LoginAuditRepository : JpaRepository<LoginAudit, Long>
7 changes: 4 additions & 3 deletions src/main/kotlin/fi/hsl/jore4/auth/audit/LoginAuditService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package fi.hsl.jore4.auth.audit

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

/**
* Service for logging login events.
* Only enabled when JPA is available.
*/
@Service
@ConditionalOnBean(LoginAuditRepository::class)
@ConditionalOnProperty(prefix = "session", name = ["enabled"], havingValue = "true")
open class LoginAuditService(
@Autowired(required = true)
private val loginAuditRepository: LoginAuditRepository
) {
companion object {
Expand Down
Loading