brockallen / BrockAllen.MembershipReboot

MembershipReboot is a user identity management and authentication library.
Other
742 stars 238 forks source link

.GetPasswordResetKey() crash. #584

Closed minajevs closed 9 years ago

minajevs commented 9 years ago

Recently got that crash on production, where one user can't reset his password. The call is .GetPasswordResetKey(”whatever@mail.com”).

Stacktrace:

    System.InvalidOperationException: Sequence contains more than one element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
   at BrockAllen.MembershipReboot.EventBusUserAccountRepository`1.GetByID(Guid id) in c:\ballen\github\brockallen\BrockAllen.MembershipReboot\src\BrockAllen.MembershipReboot\Repository\EventBusUserAccountRepository.cs:line 77
   at BrockAllen.MembershipReboot.UserAccountService`1.GetByID(Guid id) in c:\ballen\github\brockallen\BrockAllen.MembershipReboot\src\BrockAllen.MembershipReboot\AccountService\UserAccountService.cs:line 250
   at BrockAllen.MembershipReboot.UserAccountService`1.SetConfirmedEmail(Guid accountID, String email) in c:\ballen\github\brockallen\BrockAllen.MembershipReboot\src\BrockAllen.MembershipReboot\AccountService\UserAccountService.cs:line 1705
   at MembershipRebootUserRepository.CustomUserService.SetVerificationKey(Guid id, String email) in c:\some\folder\what\ever\IdentityRepository\CustomUserService.cs:line 20
   at MembershipRebootUserRepository.MembershipManagementService.<>c__DisplayClass5_0.<GetPasswordResetKey>b__0() in c:\some\folder\what\ever\IdentityRepository\MembershipManagementService.cs:line 111
   at MembershipRebootUserRepository.MembershipManagementService.ExecuteOperation[T](Func`1 operation) in c:\some\folder\what\ever\IdentityRepository\MembershipManagementService.cs:line 221
   at MembershipRebootUserRepository.MembershipManagementService.GetPasswordResetKey(String email) in c:\some\folder\what\ever\IdentityRepository\MembershipManagementService.cs:line 102
   at SyncInvokeGetPasswordResetKey(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)]:Sequence contains more than one element

We are using membership reboot + identity server 2. It's weird that only one user gets this error. That "Sequence contains more than one element" makes me think that there are several accounts registred with one email with same ID. Is that even possible? I hope you can help me.

brockallen commented 9 years ago

I guess it's possible unless you put a constraint on the DB. I'd check and see if 2 rows are there.

minajevs commented 9 years ago

Ok, I checked UserAccounts DB and all the IDs and emails are unique. What else can cause that crash?

brockallen commented 9 years ago

GetByID is failing and it's searching by that ID -- so check for that ID being duplicate (but that doesn't make much sense to me).

minajevs commented 9 years ago

Yeah, already checked ID for that user and it's unique. Damn, I am stuck

brockallen commented 9 years ago

Well, given the exception and the call stack I am unsure. From the code it looks like the ID is being searched. One last thing to check is to see if the verification key is duplicated.

minajevs commented 9 years ago

Well, everything is unique in the database. Looks like I need to check logs again.

brockallen commented 9 years ago

The last idea is to enable logging -- that way you can watch the path as the execution flows thru the code.

minajevs commented 9 years ago

Ok, it was a long night, but the problem was found. It appeared that before passwordresetkey every e-mail was verified through external service which I have no access to, and somehow that service returned that exact mail twice. Problem is fixed now, thanks for help!

brockallen commented 9 years ago

Good to hear. Thx