【问题标题】:Can't update users email address or password using Thinktecture IdMgr + MembershipReboot.无法使用 Thinktecture IdMgr + MembershipReboot 更新用户电子邮件地址或密码。
【发布时间】:2015-05-27 14:44:16
【问题描述】:

当我在 Thinktecture IdManager 中编辑用户时,我可以更改他们的姓名、年龄和其他“自定义”属性,但是当我尝试更改他们的电子邮件地址或密码时,我的自定义 Membership Reboot 存储库更新方法会被调用一次以保存更改然后再次还原更改。

控制器由于某种原因被 AutoFac 容器中间件调用了两次。

只有 1 个来自 IdMgr 应用程序的 HTTP 帖子,因此这不是客户端问题。

第一个堆栈跟踪是...

Gaist.Authentication.dll!Gaist.Authentication.MR.MembershipRebootRepository.Update(Gaist.Authentication.Mongo.Models.CustomUser item) Line 71    C#
[External Code]    
IdentityManager.MembershipReboot.dll!IdentityManager.MembershipReboot.MembershipRebootIdentityManagerService<Gaist.Authentication.Mongo.Models.CustomUser,Gaist.Authentication.Mongo.Models.CustomGroup>.SetPassword(Gaist.Authentication.Mongo.Models.CustomUser account, string password) Line 235    C#
IdentityManager.dll!IdentityManager.ExpressionPropertyMetadata<Gaist.Authentication.Mongo.Models.CustomUser,string>.Set(object instance, string value) Line 87    C#
IdentityManager.dll!IdentityManager.PropertyMetadataExtensions.TrySet(IdentityManager.PropertyMetadata property, object instance, string value, out IdentityManager.IdentityManagerResult result) Line 137    C#
IdentityManager.dll!IdentityManager.PropertyMetadataExtensions.TrySet(System.Collections.Generic.IEnumerable<IdentityManager.PropertyMetadata> properties, object instance, string type, string value, out IdentityManager.IdentityManagerResult result) Line 123    C#
IdentityManager.MembershipReboot.dll!IdentityManager.MembershipReboot.MembershipRebootIdentityManagerService<Gaist.Authentication.Mongo.Models.CustomUser,Gaist.Authentication.Mongo.Models.CustomGroup>.SetUserProperty(System.Collections.Generic.IEnumerable<IdentityManager.PropertyMetadata> propsMeta, Gaist.Authentication.Mongo.Models.CustomUser user, string type, string value) Line 590    C#
IdentityManager.MembershipReboot.dll!IdentityManager.MembershipReboot.MembershipRebootIdentityManagerService<Gaist.Authentication.Mongo.Models.CustomUser,Gaist.Authentication.Mongo.Models.CustomGroup>.SetUserPropertyAsync(string subject, string type, string value) Line 503    C#
IdentityManager.dll!IdentityManager.Api.Models.Controllers.UserController.SetPropertyAsync(string subject, string type) Line 205    C#
[External Code]    
IdentityManager.dll!IdentityManager.Configuration.Hosting.KatanaDependencyResolver.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Line 35    C#
[External Code]    
IdentityManager.dll!IdentityManager.Configuration.Hosting.AutofacContainerMiddleware.Invoke(System.Collections.Generic.IDictionary<string,object> env) Line 51    C#
[External Code]    
IdentityManager.dll!Owin.IdentityManagerAppBuilderExtensions.UseIdentityManager(Microsoft.Owin.IOwinContext ctx, System.Func<System.Threading.Tasks.Task> next) Line 55    C#
[Resuming Async Method]    
[External Code]

第二个堆栈跟踪是...

Gaist.Authentication.dll!Gaist.Authentication.MR.MembershipRebootRepository.Update(Gaist.Authentication.Mongo.Models.CustomUser item) Line 71   C#
[External Code] 
IdentityManager.MembershipReboot.dll!IdentityManager.MembershipReboot.MembershipRebootIdentityManagerService<Gaist.Authentication.Mongo.Models.CustomUser,Gaist.Authentication.Mongo.Models.CustomGroup>.SetUserPropertyAsync(string subject, string type, string value) Line 511   C#
IdentityManager.dll!IdentityManager.Api.Models.Controllers.UserController.SetPropertyAsync(string subject, string type) Line 205    C#
[External Code] 
IdentityManager.dll!IdentityManager.Configuration.Hosting.KatanaDependencyResolver.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Line 35  C#
[External Code] 
IdentityManager.dll!IdentityManager.Configuration.Hosting.AutofacContainerMiddleware.Invoke(System.Collections.Generic.IDictionary<string,object> env) Line 51  C#
[External Code] 
IdentityManager.dll!Owin.IdentityManagerAppBuilderExtensions.UseIdentityManager(Microsoft.Owin.IOwinContext ctx, System.Func<System.Threading.Tasks.Task> next) Line 55 C#
[Resuming Async Method] 
[External Code] 

【问题讨论】:

    标签: thinktecture membershipreboot


    【解决方案1】:

    发生这种情况是因为开箱即用的 MembershipRebootIdentityManagerService 实现假设存储库将基于实体框架,并且调用 save 两次将在 EF 上下文的同一实例上工作,因此在同一实体上工作。

    我的 repo 实现不是这样工作的,所以它加载了一个未保存的实体,然后覆盖了设置。

    我不得不冻结我的存储库以在存储库的生命周期内保留正在编辑的实体。

    【讨论】:

      猜你喜欢
      • 2020-12-25
      • 2023-02-23
      • 2021-08-18
      • 2022-01-19
      • 2012-07-23
      • 2020-04-19
      • 2015-09-30
      • 2011-09-09
      • 2015-03-28
      相关资源
      最近更新 更多