Skip to content

Instantly share code, notes, and snippets.

@pascalmouret
Created January 13, 2015 17:07
Show Gist options
  • Save pascalmouret/6f6bdca5cd72c6496be0 to your computer and use it in GitHub Desktop.
Save pascalmouret/6f6bdca5cd72c6496be0 to your computer and use it in GitHub Desktop.
magnets.scala
def logLogin(magnet: LogLoginMagnet): Route => Route = magnet()
sealed trait LogLoginMagnet {
def apply(): Route => Route
}
object LogLoginMagnet {
implicit def withImplicits(token: Token, channel: String)(implicit serviceLayers: ServiceLayers, networkId: NetworkId): LogLoginMagnet =
new LogLoginMagnet {
def apply(): Route = {
import serviceLayers.LogLoginServiceLayer
Future {
if (token.isUser) {
val userId = UserId(token.userId.value)
// TODO: log ip address
val log = LogLogin(userId = userId, channel = channel, ipAddress = "")
LogLoginServiceLayer.save(log)
}
}
pass
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment