Changed ID creation to use TransformTypeCollectionNameToDocumentIdPrefix for collection name.

This commit is contained in:
Josh Close
2019-07-07 21:37:36 -05:00
parent 09396baf35
commit c53464cd47
3 changed files with 9 additions and 5 deletions
+2 -1
View File
@@ -49,9 +49,10 @@ namespace Raven.Identity
var vals = new[] { userId, loginProvider, name }
.Select(v => v ?? "[null]");
var collection = db.Conventions.GetCollectionName(typeof(IdentityUserAuthToken));
var prefix = db.Conventions.TransformTypeCollectionNameToDocumentIdPrefix(collection);
var separator = db.Conventions.IdentityPartsSeparator;
var valsHash = CalculateHash(string.Join("-", vals));
return collection + separator + valsHash.ToString();
return prefix + separator + valsHash.ToString();
}
private static int CalculateHash(string input)
+2 -1
View File
@@ -414,8 +414,9 @@ namespace Raven.Identity
internal static string GetRavenIdFromRoleName(string role, IDocumentStore docStore)
{
var roleCollection = docStore.Conventions.GetCollectionName(typeof(TRole));
var prefix = docStore.Conventions.TransformTypeCollectionNameToDocumentIdPrefix(roleCollection);
var partSeparator = docStore.Conventions.IdentityPartsSeparator;
return roleCollection + partSeparator + role;
return prefix + partSeparator + role;
}
}
}
+5 -3
View File
@@ -129,8 +129,9 @@ namespace Raven.Identity
{
var conventions = DbSession.Advanced.DocumentStore.Conventions;
var entityName = conventions.GetCollectionName(typeof(TUser));
var prefix = conventions.TransformTypeCollectionNameToDocumentIdPrefix(entityName);
var separator = conventions.IdentityPartsSeparator;
var id = $"{entityName}{separator}{user.Email}";
var id = $"{prefix}{separator}{user.Email}";
user.Id = id;
}
@@ -389,10 +390,11 @@ namespace Raven.Identity
ThrowIfNullDisposedCancelled(user, cancellationToken);
// See if we have an IdentityRole with that name.
var identityUserPrefix = DbSession.Advanced.DocumentStore.Conventions.GetCollectionName(typeof(IdentityRole));
var identityUserCollection = DbSession.Advanced.DocumentStore.Conventions.GetCollectionName(typeof(IdentityRole));
var prefix = DbSession.Advanced.DocumentStore.Conventions.TransformTypeCollectionNameToDocumentIdPrefix(identityUserCollection);
var identityPartSeperator = DbSession.Advanced.DocumentStore.Conventions.IdentityPartsSeparator;
var roleNameLowered = roleName.ToLowerInvariant();
var roleId = identityUserPrefix + identityPartSeperator + roleNameLowered;
var roleId = prefix + identityPartSeperator + roleNameLowered;
var existingRoleOrNull = await this.DbSession.LoadAsync<IdentityRole>(roleId, cancellationToken);
if (existingRoleOrNull == null)
{