【发布时间】:2012-07-18 04:05:59
【问题描述】:
我正试图围绕 CQRS。我从here 提供的代码示例中提取。请温柔,我对这种模式很陌生。
我正在查看登录方案。我喜欢这种情况,因为在我读过的任何示例中都没有真正体现出来。在这种情况下,我不知道用户的聚合 ID 是什么,或者即使有一个,因为我一开始只是用户名和密码。
在 fohjin 示例中,事件总是从域中触发(如果需要),并且命令处理程序调用域上的某些方法。但是,如果用户登录无效,我就没有域可以调用任何东西。此外,fohjin 项目中定义的大多数(如果不是全部)基本命令/事件类都传递一个聚合 id。
如果发生 LogonFailure 事件,我可能想要更新 LogonAudit 报告。
所以我的问题是:如何处理无法解析为特定聚合的命令?那会怎样?
public void Execute(UserLogonCommand command)
{
var user = null;//user looked up by username somehow, should i query the report database to resolve the username to an id?
if (user == null || user.Password != command.Password)
;//What to do here? I want to raise an event somehow that doesn't target a specific user
else
user.LogonSuccessful();
}
【问题讨论】:
-
我在 CQRS+ES 上写了一个 MembershipProvider,如果你 want to take a look,这是我的尝试之一
-
感谢帮助。它似乎忽略了与现有用户名不匹配的登录尝试的记录。这是我问题的核心
-
失败的尝试存储在 Faliedpassword 尝试和 FailedPasswordQuestionAndAnswerAttempt 和相对日期时间中
标签: cqrs