diff --git a/src/identity.documentdb/ElCamino.AspNet.Identity.DocumentDB.csproj b/src/identity.documentdb/ElCamino.AspNet.Identity.DocumentDB.csproj
index 3baffa4..7b5623e 100644
--- a/src/identity.documentdb/ElCamino.AspNet.Identity.DocumentDB.csproj
+++ b/src/identity.documentdb/ElCamino.AspNet.Identity.DocumentDB.csproj
@@ -52,8 +52,8 @@
..\..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll
True
-
- ..\..\packages\Microsoft.Azure.DocumentDB.1.12.0\lib\net45\Microsoft.Azure.Documents.Client.dll
+
+ ..\..\packages\Microsoft.Azure.DocumentDB.1.13.1\lib\net45\Microsoft.Azure.Documents.Client.dll
..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
@@ -108,7 +108,9 @@
Designer
-
+
+ Designer
+
@@ -143,11 +145,11 @@
-
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
+
\ No newline at end of file
diff --git a/src/identity.documentdb/ElCamino.AspNet.Identity.DocumentDB.nuspec b/src/identity.documentdb/ElCamino.AspNet.Identity.DocumentDB.nuspec
index fc0ae31..0df3fe5 100644
--- a/src/identity.documentdb/ElCamino.AspNet.Identity.DocumentDB.nuspec
+++ b/src/identity.documentdb/ElCamino.AspNet.Identity.DocumentDB.nuspec
@@ -12,7 +12,8 @@
$description$
Release $version$ This project is an open source plugin to ASP.NET Identity framework using Azure DocumentDB.
- * Updating references.
+ * Adding configurable collection names.
+ * Updating DocumentDB client reference.
Copyright 2017
ASP.NET Identity 2.0 Azure DocumentDB Storage MVC UserStore RoleStore UserManager
diff --git a/src/identity.documentdb/Helpers/UriEncodeKeyHelper.cs b/src/identity.documentdb/Helpers/UriEncodeKeyHelper.cs
index f3d906d..79e6ecc 100644
--- a/src/identity.documentdb/Helpers/UriEncodeKeyHelper.cs
+++ b/src/identity.documentdb/Helpers/UriEncodeKeyHelper.cs
@@ -57,7 +57,7 @@ public override string GenerateRowKeyIdentityUserLogin(string loginProvider, str
public override double KeyVersion
{
- get { return 1.2; }
+ get { return 1.3; }
}
}
}
diff --git a/src/identity.documentdb/IdentityCloudContext.cs b/src/identity.documentdb/IdentityCloudContext.cs
index 587ca8f..ccdc880 100644
--- a/src/identity.documentdb/IdentityCloudContext.cs
+++ b/src/identity.documentdb/IdentityCloudContext.cs
@@ -19,17 +19,15 @@ public IdentityCloudContext()
: base()
{ }
- public IdentityCloudContext(string uri, string authKey, string database, ConnectionPolicy policy = null)
- : base(uri, authKey, database, policy)
+ public IdentityCloudContext(string uri, string authKey, string database, ConnectionPolicy policy = null,
+ string usersCollectionName = null, string rolesCollectionName = null)
+ : base(uri, authKey, database, policy, usersCollectionName, rolesCollectionName)
{ }
public IdentityCloudContext(string usersCollectionName, string rolesCollectionName)
: base(usersCollectionName, rolesCollectionName)
{ }
- public IdentityCloudContext(string uri, string authKey, string database, ConnectionPolicy policy, string usersCollectionName, string rolesCollectionName)
- : base(uri, authKey, database, policy, usersCollectionName, rolesCollectionName)
- { }
}
public class IdentityCloudContext : IdentityCloudContext where TUser : IdentityUser
@@ -38,17 +36,15 @@ public IdentityCloudContext()
: base()
{ }
- public IdentityCloudContext(string uri, string authKey, string database, ConnectionPolicy policy = null)
- : base(uri, authKey, database, policy)
+ public IdentityCloudContext(string uri, string authKey, string database, ConnectionPolicy policy = null,
+ string usersCollectionName = null, string rolesCollectionName = null)
+ : base(uri, authKey, database, policy, usersCollectionName, rolesCollectionName)
{ }
public IdentityCloudContext(string usersCollectionName, string rolesCollectionName)
: base(usersCollectionName, rolesCollectionName)
{ }
- public IdentityCloudContext(string uri, string authKey, string database, ConnectionPolicy policy, string usersCollectionName, string rolesCollectionName)
- : base(uri, authKey, database, policy, usersCollectionName, rolesCollectionName)
- { }
}
@@ -108,14 +104,12 @@ public IdentityCloudContext(string usersCollectionName, string rolesCollectionNa
}
- public IdentityCloudContext(string uri, string authKey, string database, ConnectionPolicy policy = null) :
- this(uri, authKey, database, policy, Constants.DocumentCollectionIds.UsersCollection, Constants.DocumentCollectionIds.RolesCollection)
- { }
-
- public IdentityCloudContext(string uri, string authKey, string database, ConnectionPolicy policy, string usersCollection, string rolesCollection)
+ public IdentityCloudContext(string uri, string authKey, string database, ConnectionPolicy policy = null,
+ string usersCollection = null,
+ string rolesCollection = null)
{
- _userDocumentCollection = new DocumentCollection { Id = usersCollection };
- _roleDocumentCollection = new DocumentCollection { Id = rolesCollection };
+ _userDocumentCollection = new DocumentCollection { Id = usersCollection?? Constants.DocumentCollectionIds.UsersCollection };
+ _roleDocumentCollection = new DocumentCollection { Id = rolesCollection?? Constants.DocumentCollectionIds.RolesCollection };
_client = new DocumentClient(new Uri(uri), authKey, policy, ConsistencyLevel.Session);
InitDatabase(database);
@@ -177,14 +171,14 @@ private void InitCollections()
var ucTask = _client.CreateDocumentCollectionIfNotExistsAsync(_db.SelfLink, _userDocumentCollection);
ucTask.Wait();
var uc = ucTask.Result;
- UserDocumentCollection = uc;
+ UserDocumentCollection = uc;
}),
new TaskFactory().StartNew(() =>
{
var rcTask = _client.CreateDocumentCollectionIfNotExistsAsync(_db.SelfLink, _roleDocumentCollection);
rcTask.Wait();
var rc = rcTask.Result;
- RoleDocumentCollection = rc;
+ RoleDocumentCollection = rc;
})
};
Task.WaitAll(tasks);
diff --git a/src/identity.documentdb/Properties/AssemblyInfo.cs b/src/identity.documentdb/Properties/AssemblyInfo.cs
index 20f373c..af5a590 100644
--- a/src/identity.documentdb/Properties/AssemblyInfo.cs
+++ b/src/identity.documentdb/Properties/AssemblyInfo.cs
@@ -18,7 +18,7 @@
[assembly: Guid("29B22384-59C4-40E9-B59F-346666629742")]
//http://semver.org/
-[assembly: AssemblyVersion("1.2.0.0")]
-[assembly: AssemblyFileVersion("1.2.0.0")]
-[assembly: AssemblyInformationalVersion("1.2.0.0")]
+[assembly: AssemblyVersion("1.3.0.0")]
+[assembly: AssemblyFileVersion("1.3.0.0")]
+[assembly: AssemblyInformationalVersion("1.3.0.0")]
diff --git a/src/identity.documentdb/UserStore.cs b/src/identity.documentdb/UserStore.cs
index eba586c..03b76d8 100644
--- a/src/identity.documentdb/UserStore.cs
+++ b/src/identity.documentdb/UserStore.cs
@@ -171,8 +171,10 @@ public async virtual Task DeleteAsync(TUser user)
throw new ArgumentNullException("user");
}
- await Context.Client.DeleteDocumentAsync(user.SelfLink,
+ var result = await Context.Client.DeleteDocumentAsync(user.SelfLink,
Context.RequestOptions);
+ Context.SetSessionTokenIfEmpty(result.SessionToken);
+
}
public void Dispose()
@@ -205,27 +207,21 @@ public async virtual Task FindAsync(UserLoginInfo login)
string loginId = login.GenerateRowKeyUserLoginInfo();
var result = await Context.Client.ExecuteStoredProcedureAsync>(Context.GetUserByLoginSproc.SelfLink,
+ Context.RequestOptions,
new dynamic[] { loginId });
- if (result.Response != null)
- {
- Context.SetSessionTokenIfEmpty(result.SessionToken);
- return GetUserAggregate(result.Response.ToList());
- }
- return null;
+ Context.SetSessionTokenIfEmpty(result.SessionToken);
+ return GetUserAggregate(result.Response.ToList());
}
public async Task FindByEmailAsync(string plainEmail)
{
var result = await Context.Client.ExecuteStoredProcedureAsync>(Context.GetUserByEmailSproc.SelfLink,
+ Context.RequestOptions,
new dynamic[] { plainEmail });
- if (result.Response != null)
- {
Context.SetSessionTokenIfEmpty(result.SessionToken);
return GetUserAggregate(result.Response.ToList());
- }
- return null;
}
public virtual async Task FindByIdAsync(TKey userId)
@@ -238,13 +234,10 @@ public async virtual Task FindByNameAsync(string userName)
{
this.ThrowIfDisposed();
var result = await Context.Client.ExecuteStoredProcedureAsync>(Context.GetUserByUserNameSproc.SelfLink,
+ Context.RequestOptions,
new dynamic[] { userName });
- if (result.Response != null)
- {
- Context.SetSessionTokenIfEmpty(result.SessionToken);
- return await Task.FromResult(GetUserAggregate(result.Response.ToList()));
- }
- return null;
+ Context.SetSessionTokenIfEmpty(result.SessionToken);
+ return await Task.FromResult(GetUserAggregate(result.Response.ToList()));
}
public Task GetAccessFailedCountAsync(TUser user)
@@ -380,15 +373,14 @@ public Task GetTwoFactorEnabledAsync(TUser user)
private async Task GetUserAggregateAsync(string userId)
{
- var task = Context.Client.ExecuteStoredProcedureAsync>(Context.GetUserByIdSproc.SelfLink,
- new dynamic[] { userId });
- task.Wait();
- if (task.Result.Response != null)
- {
- return await Task.FromResult(GetUserAggregate(task.Result.Response.ToList()));
- }
- return null;
-
+ return await Context.Client.ExecuteStoredProcedureAsync>(Context.GetUserByIdSproc.SelfLink,
+ Context.RequestOptions,
+ new dynamic[] { userId })
+ .ContinueWith((storedProcTask) => {
+ Context.SetSessionTokenIfEmpty(storedProcTask.Result.SessionToken);
+ return GetUserAggregate(storedProcTask.Result.Response.ToList());
+ });
+
}
private TUser GetUserAggregate(List userResults)
diff --git a/src/identity.documentdb/packages.config b/src/identity.documentdb/packages.config
index db8a7c7..945eb78 100644
--- a/src/identity.documentdb/packages.config
+++ b/src/identity.documentdb/packages.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/tests/identity.documentdb.tests/ElCamino.AspNet.Identity.DocumentDB.Tests.csproj b/tests/identity.documentdb.tests/ElCamino.AspNet.Identity.DocumentDB.Tests.csproj
index 044355e..5ebe031 100644
--- a/tests/identity.documentdb.tests/ElCamino.AspNet.Identity.DocumentDB.Tests.csproj
+++ b/tests/identity.documentdb.tests/ElCamino.AspNet.Identity.DocumentDB.Tests.csproj
@@ -56,8 +56,8 @@
..\..\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll
True
-
- ..\..\packages\Microsoft.Azure.DocumentDB.1.12.0\lib\net45\Microsoft.Azure.Documents.Client.dll
+
+ ..\..\packages\Microsoft.Azure.DocumentDB.1.13.1\lib\net45\Microsoft.Azure.Documents.Client.dll
..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
@@ -127,12 +127,12 @@
-
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
+