Created
January 13, 2015 17:07
-
-
Save pascalmouret/6f6bdca5cd72c6496be0 to your computer and use it in GitHub Desktop.
magnets.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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