JudahGabriel / RavenDB.Identity

RavenDB Identity provider for ASP.NET Core. Let RavenDB manage your users and logins.
https://www.nuget.org/packages/RavenDB.Identity/1.0.0
MIT License
61 stars 29 forks source link

Delete user fails with ConcurrencyFailure #8

Closed marcuslindblom closed 5 years ago

marcuslindblom commented 5 years ago

I use the 6.0.1 and when I try to delete a user I get the error Unable to delete user email compare/exchange value. I use RavenDB 4.1.3.

marcuslindblom commented 5 years ago

According to the documentation it seems like you first need to get the current value and then use the index when you delete the key. It seems like you always put 0 as the index in the DeleteCompareExchangeValueOperation

From the docs

// First, get existing value
CompareExchangeValue<User> readResult =
    store.Operations.Send(
        new GetCompareExchangeValueOperation<User>("AdminUser"));

// Delete the key - use the index received from the 'Get' operation
CompareExchangeResult<User> deleteResult
    = store.Operations.Send(
        new DeleteCompareExchangeValueOperation<User>("AdminUser", readResult.Index));

// The delete result is successful only if the index has not changed between the read and delete operations
bool deleteResultSuccessful = deleteResult.Successful;

https://ravendb.net/docs/article-page/4.1/csharp/client-api/operations/compare-exchange/delete-compare-exchange-value

JudahGabriel commented 5 years ago

Investigating. I'll get back to you today with a fix.

JudahGabriel commented 5 years ago

OK Marcus, this is fixed. I've published an update to NuGet (v6.0.2) as well.

Thanks for the bug report.