login fix and spaces creation

This commit is contained in:
xds
2025-03-06 18:55:12 +03:00
parent 3b9f0e566c
commit 98263732ca
5 changed files with 71 additions and 77 deletions

View File

@@ -1,5 +1,6 @@
package space.luminic.budgerapp.services
import kotlinx.coroutines.reactor.awaitSingle
import org.springframework.cache.annotation.CacheEvict
import org.springframework.stereotype.Service
import reactor.core.publisher.Mono
@@ -12,14 +13,14 @@ import java.time.LocalDateTime
class TokenService(private val tokenRepository: TokenRepo) {
@CacheEvict("tokens", allEntries = true)
fun saveToken(token: String, username: String, expiresAt: LocalDateTime): Mono<Token> {
suspend fun saveToken(token: String, username: String, expiresAt: LocalDateTime): Token {
val newToken = Token(
token = token,
username = username,
issuedAt = LocalDateTime.now(),
expiresAt = expiresAt
)
return tokenRepository.save(newToken)
return tokenRepository.save(newToken).awaitSingle()
}
fun getToken(token: String): Mono<Token> {