在 play2 scala zentasks 示例应用程序中,代码片段如下所示
def IsAuthenticated(f: => String => Request[AnyContent] => Result) =
Security.Authenticated(username, onUnauthorized) { user =>
Action(request => f(user)(request))
}
我需要做的是在模型中调用这个函数
def AddOnline(email: String, contact: Contact) = {
DB.withConnection { implicit connection =>
SQL(
"""
update contact
set online_status = {'online'} //I want to write the value contact.status=online
where email = {email}
"""
).on(
'email -> contact.email,
'online_status -> contact.online_status
).executeUpdate()
}
}
AddOnline
但我在这里的挑战是每次通过上述代码对某个用户进行身份验证时调用此函数。有人可以建议我该怎么做吗?我是这方面的新手,我兜兜转转,没有任何进展