Fixed current user data
This commit is contained in:
parent
482079fb8f
commit
cc3fe8ae96
@ -35,6 +35,14 @@ class AuthService(
|
||||
return !(authentication == null || authentication is AnonymousAuthenticationToken || authentication.principal == null)
|
||||
}
|
||||
|
||||
fun parseJoinDate(joinDate: String?): OffsetDateTime? {
|
||||
return try {
|
||||
if(joinDate == null) null else OffsetDateTime.parse(joinDate)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun getCurrentUser(): UserInfo {
|
||||
if(!this.isLoggedIn())
|
||||
throw IllegalStateException("User is not logged in")
|
||||
@ -45,8 +53,8 @@ class AuthService(
|
||||
return UserInfo(
|
||||
userId = (userDetails.attributes["id"] as Int).toLong(),
|
||||
username = userDetails.attributes["username"] as String,
|
||||
country = userDetails.attributes["countryCode"] as String?,
|
||||
joinDate = OffsetDateTime.parse(userDetails.attributes["joinDate"] as String)
|
||||
country = userDetails.attributes["country_code"] as String?,
|
||||
joinDate = parseJoinDate(userDetails.attributes["join_date"] as String?)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user