我正在使用Silhouette来管理我的Play应用程序中的身份验证。注册,登录和授权工作正常。但是,尝试注销 (= 删除( 用户帐户时,删除相应的身份验证信息将失败。
特别是,以下行引发异常:
authInfoRepository.remove(LoginInfo(credentialsProvider.id, username))
(authInfoRepository
是一个注入的AuthInfoRepository
,它被配置为一个DelegableAuthInfoRepository
(
例外:
com.mohiva.play.silhouette.api.exceptions.ConfigurationException: Cannot remove auth info of type: class scala.runtime.Nothing$; Please configure the DAO for this type
at com.mohiva.play.silhouette.persistence.repositories.DelegableAuthInfoRepository.remove(DelegableAuthInfoRepository.scala:115)
[...]
查看所讨论的方法,它期望隐式参数implicit tag: ClassTag[T]
。那个不知何故最终被Nothing
,这在我眼中看起来不对劲,但我不完全明白发生了什么,或者预期会发生什么。
- 应该如何正确称呼
AuthInfoRepository#remove
?我是否需要手动将ClassTag
对象放入正确的上下文中以避免推断Nothing
? - 为什么隐式
ClassTag
参数甚至相关?
为什么隐式
ClassTag
参数甚至相关?
ClassTag
是相关的,因为remove
期望这样的隐含:https://github.com/mohiva/play-silhouette/blob/master/silhouette-persistence/src/main/scala/com/mohiva/play/silhouette/persistence/repositories/DelegableAuthInfoRepository.scala#L104-L118
我是否需要手动将
ClassTag
对象放入正确的上下文中以 避免Nothing
被推断?
我想反之亦然,您应该指定T
(如果没有这样的指定,现在推断T
是Nothing
(,并且会找到适当的隐式。
尝试以下选项之一:
authInfoRepository.remove[CasInfo](LoginInfo(credentialsProvider.id, username))
authInfoRepository.remove[OAuth1Info](LoginInfo(credentialsProvider.id, username))
authInfoRepository.remove[OAuth2Info](LoginInfo(credentialsProvider.id, username))
authInfoRepository.remove[OpenIDInfo](LoginInfo(credentialsProvider.id, username))
authInfoRepository.remove[PasswordInfo](LoginInfo(credentialsProvider.id, username))