NCQRS:如何从域加载?
采用标准注册流程:
用户注册
用户收到包含激活帐户链接的电子邮件
用户激活帐户
我所说的问题是:
当我们创建初始帐户时,我们存储用户名、密码、电子邮件、激活密钥
当用户单击激活密钥链接时,我们使用读取模型验证密钥
然后触发传入用户名的ActivateAccountCommand
如何加载用户帐户以在域中激活它?
最初我想将新用户 Acount.Id 传递给 readmodel,但 CommandExecutorBase 中没有访问权限(据我所知) - 我们不保存此内容:
protected override void ExecuteInContext(IUnitOfWorkContext context,
CreateAccountViaFormRegistrationCommand command)
{
var newKey = Guid.NewGuid().ToString();
var newAccount = new Account(
command.UserName, command.Email, command.Password, newKey);
SendWelcomeEmail(command.Email, command.UserName, newKey);
context.Accept();
}
Take the standard registration process:
user signs up
user is sent email with link activate account
user activates account
the issue i'm talking about is:
when we create the initial account we store the username, password, email, activation key
when the user clicks the activation key link we validate the key using the readmodel
we then fire the ActivateAccountCommand passing in the username
how do i load the users account to activate it in the domain?
initially I wanted to pass the new users Acount.Id to the readmodel but there is no access (that i'm aware of) from within the CommandExecutorBase - we don't save this:
protected override void ExecuteInContext(IUnitOfWorkContext context,
CreateAccountViaFormRegistrationCommand command)
{
var newKey = Guid.NewGuid().ToString();
var newAccount = new Account(
command.UserName, command.Email, command.Password, newKey);
SendWelcomeEmail(command.Email, command.UserName, newKey);
context.Accept();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以发布一个
AccountActivationKeySent
事件,该事件又可以被处理以填充读取端所需的任何投影。大致如下:You can publish an
AccountActivationKeySent
event, which in turn can be handled to populate whatever projection you need on the read side. Something along the lines of: