Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun createJwt(userId: UUID): Either<TokenCreationException, String> =
- Either.fx<TokenCreationException, String> {
- val audience = audience.mapLeft { TokenCreationException(it) }.bind()
- val algorithmSecret = algorithmSecret.mapLeft { TokenCreationException(it) }.bind()
- val algorithm = algorithm(algorithmSecret)
- .mapLeft { TokenCreationException(it) }.bind()
- JWT.create()
- .withAudience(audience)
- .withIssuer(userId.toString())
- .withExpiresAt(OffsetDateTime.now().plusDays(1).let { Date.from(it.toInstant()) })
- .sign(algorithm)
- }.fix()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement