Skip to content

Commit 2ac7738

Browse files
author
Jony Santos
committed
updating to spring boot 2.0.3 and kotlin 1.12.50
1 parent d51ed41 commit 2ac7738

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>1.5.3.RELEASE</version>
17+
<version>2.0.3.RELEASE</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

@@ -23,7 +23,7 @@
2323
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2424
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2525
<java.version>1.8</java.version>
26-
<kotlin.version>1.1.2-4</kotlin.version>
26+
<kotlin.version>1.2.50</kotlin.version>
2727
</properties>
2828

2929
<dependencies>

src/main/kotlin/br/com/jonyfs/springbootkotlinapi/LoadData.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class LoadData {
108108
userAdmin.password = "XPTO"
109109
userAdmin.roles = (listOf(roleAdmin))
110110

111-
userRepository.save(listOf(user1, user2, user3, user4, userAdmin))
111+
userRepository.saveAll(listOf(user1, user2, user3, user4, userAdmin))
112112
}
113113

114114
}

src/main/kotlin/br/com/jonyfs/springbootkotlinapi/config/AuditConfig.kt

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package br.com.jonyfs.springbootkotlinapi.config
44
* Created by jony on 28/05/17.
55
*/
66
import br.com.jonyfs.springbootkotlinapi.user.User
7+
import java.util.Optional
78
import org.springframework.context.annotation.Bean
89
import org.springframework.context.annotation.Configuration
910
import org.springframework.data.domain.AuditorAware
@@ -31,14 +32,19 @@ class AuditingConfig {
3132

3233
class SecurityAuditor : AuditorAware<User> {
3334

34-
override fun getCurrentAuditor(): User? {
35+
override fun getCurrentAuditor(): Optional<User>? {
3536
val auth = SecurityContextHolder.getContext().authentication
36-
if (auth != null) {
37+
if (auth == null) {
38+
return Optional.empty()
39+
} else {
3740
if (auth.details is User) {
38-
return auth.details as User
41+
return Optional.of(auth.details as User)
42+
}
43+
else{
44+
return Optional.empty()
3945
}
4046
}
41-
return null
47+
4248
}
4349
}
4450

0 commit comments

Comments
 (0)