Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustNagro committed Dec 3, 2024
1 parent 0ca3ff5 commit bd4b134
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DB(dataSource: DataSource & Closeable) extends Logging with AutoCloseable:
/** Runs `f` in a transaction. The transaction is commited if the result is a [[Right]], and rolled back otherwise. */
def transactEither[E, T](f: DbTx ?=> Either[E, T])(using IO): Either[E, T] =
try com.augustnagro.magnum.transact(transactor)(Right(f.fold(e => throw LeftException(e), identity)))
catch case e: LeftException[E] => Left(e.left)
catch case e: LeftException[?] => Left(e.asInstanceOf[LeftException[E]].left)

/** Runs `f` in a transaction. The result cannot be an `Either`, as then [[transactEither]] should be used. The transaction is commited if
* no exception is thrown.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ class ApiKeyService(apiKeyModel: ApiKeyModel, idGenerator: IdGenerator, clock: C
def invalidateAllForUser(userId: Id[User])(using DbTx): Unit =
logger.debug(s"Invalidating all api keys for user $userId")
apiKeyModel.deleteAllForUser(userId)

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.softwaremill.bootzooka.logging.Logging
import com.softwaremill.bootzooka.user.User
import com.softwaremill.bootzooka.util.*
import com.softwaremill.bootzooka.util.Strings.Id
import ox.{IO, either, sleep}
import ox.either.{fail, ok}
import ox.{IO, sleep}

import java.security.SecureRandom
import java.time.Instant
Expand All @@ -20,7 +20,7 @@ class Auth[T](authTokenOps: AuthTokenOps[T], db: DB, clock: Clock) extends Loggi
private val random = SecureRandom.getInstance("NativePRNGNonBlocking")

/** Authenticates using the given authentication token. If the token is invalid, a [[Fail.Unauthorized]] error is returned. Otherwise,
* returns the id of the authenticated user .
* returns the id of the authenticated user .
*/
def apply(id: Id[T])(using IO): Either[Fail.Unauthorized, Id[User]] =
db.transact(authTokenOps.findById(id)) match {
Expand Down

0 comments on commit bd4b134

Please sign in to comment.