Skip to content

Commit

Permalink
Fixes issue #14.
Browse files Browse the repository at this point in the history
  • Loading branch information
Giorgos Manoltzas committed Jun 3, 2020
1 parent 1aa804f commit f19411e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
5 changes: 2 additions & 3 deletions samples/Daarto.WebUI/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using AspNetCore.Identity.Dapper;
using Daarto.WebUI.Data;
using Daarto.WebUI.Data.Tables;
using Microsoft.AspNetCore.Builder;
Expand Down Expand Up @@ -26,8 +25,8 @@ public void ConfigureServices(IServiceCollection services) {
})
.AddDefaultUI()
.AddDefaultTokenProviders();
services.AddDefaultIdentity<IdentityUser>()
.AddDapperStores();
//services.AddDefaultIdentity<IdentityUser>()
// .AddDapperStores();
services.AddControllersWithViews();
services.AddRazorPages();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<Description>Dapper implementation of ASP.NET Core Identity stores.</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFrameworks>netstandard2.1;netcoreapp3.1</TargetFrameworks>
<VersionPrefix>3.1.0</VersionPrefix>
<VersionPrefix>3.1.1</VersionPrefix>
</PropertyGroup>
<PropertyGroup Label="Package">
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>AspNetCore.Identity.DapperOrm</PackageId>
<PackageTags>AspNetCore;Dapper;Identity</PackageTags>
<PackageReleaseNotes>Update to .NET Core 3.1.</PackageReleaseNotes>
<PackageReleaseNotes>Fixes issue #14.</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/giorgos07/Daarto/tree/master/src/AspNetCore.Identity.Dapper</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
Expand Down
18 changes: 9 additions & 9 deletions src/AspNetCore.Identity.Dapper/IdentityBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,25 @@ private static void AddStores(IServiceCollection services, Type userType, Type r
if (identityRoleType == null) {
throw new InvalidOperationException($"Method {nameof(AddDapperStores)} can only be called with a role that derives from IdentityRole<TKey>.");
}
services.AddScoped(
services.TryAddScoped(
typeof(IUsersTable<,,,,,>).MakeGenericType(userType, keyType, userClaimType, userRoleType, userLoginType, userTokenType),
typeof(UsersTable<,,,,,>).MakeGenericType(userType, keyType, userClaimType, userRoleType, userLoginType, userTokenType)
);
services.AddScoped(typeof(IRolesTable<,,>).MakeGenericType(roleType, keyType, roleClaimType), typeof(RolesTable<,,>).MakeGenericType(roleType, keyType, roleClaimType));
services.AddScoped(typeof(IUserRolesTable<,,>).MakeGenericType(roleType, keyType, userRoleType), typeof(UserRolesTable<,,>).MakeGenericType(roleType, keyType, userRoleType));
services.AddScoped(typeof(IRoleClaimsTable<,>).MakeGenericType(keyType, roleClaimType), typeof(RoleClaimsTable<,>).MakeGenericType(keyType, roleClaimType));
services.TryAddScoped(typeof(IRolesTable<,,>).MakeGenericType(roleType, keyType, roleClaimType), typeof(RolesTable<,,>).MakeGenericType(roleType, keyType, roleClaimType));
services.TryAddScoped(typeof(IUserRolesTable<,,>).MakeGenericType(roleType, keyType, userRoleType), typeof(UserRolesTable<,,>).MakeGenericType(roleType, keyType, userRoleType));
services.TryAddScoped(typeof(IRoleClaimsTable<,>).MakeGenericType(keyType, roleClaimType), typeof(RoleClaimsTable<,>).MakeGenericType(keyType, roleClaimType));
services.TryAddScoped(typeof(IRoleStore<>).MakeGenericType(roleType), typeof(RoleStore<,,,>).MakeGenericType(roleType, keyType, userRoleType, roleClaimType));
userStoreType = typeof(UserStore<,,,,,,,>).MakeGenericType(userType, roleType, keyType, userClaimType, userRoleType, userLoginType, userTokenType, roleClaimType);
} else {
services.AddScoped(
services.TryAddScoped(
typeof(IUsersOnlyTable<,,,,>).MakeGenericType(userType, keyType, userClaimType, userLoginType, userTokenType),
typeof(UsersTable<,,,,,>).MakeGenericType(userType, keyType, userClaimType, typeof(IdentityRole), userLoginType, userTokenType)
typeof(UsersTable<,,,,,>).MakeGenericType(userType, keyType, userClaimType, roleType, userLoginType, userTokenType)
);
userStoreType = typeof(UserOnlyStore<,,,,>).MakeGenericType(userType, keyType, userClaimType, userLoginType, userTokenType);
}
services.AddScoped(typeof(IUserClaimsTable<,>).MakeGenericType(keyType, userClaimType), typeof(UserClaimsTable<,>).MakeGenericType(keyType, userClaimType));
services.AddScoped(typeof(IUserLoginsTable<,,>).MakeGenericType(userType, keyType, userLoginType), typeof(UserLoginsTable<,,>).MakeGenericType(userType, keyType, userLoginType));
services.AddScoped(typeof(IUserTokensTable<,>).MakeGenericType(keyType, userTokenType), typeof(UserTokensTable<,>).MakeGenericType(keyType, userTokenType));
services.TryAddScoped(typeof(IUserClaimsTable<,>).MakeGenericType(keyType, userClaimType), typeof(UserClaimsTable<,>).MakeGenericType(keyType, userClaimType));
services.TryAddScoped(typeof(IUserLoginsTable<,,>).MakeGenericType(userType, keyType, userLoginType), typeof(UserLoginsTable<,,>).MakeGenericType(userType, keyType, userLoginType));
services.TryAddScoped(typeof(IUserTokensTable<,>).MakeGenericType(keyType, userTokenType), typeof(UserTokensTable<,>).MakeGenericType(keyType, userTokenType));
services.TryAddScoped(typeof(IUserStore<>).MakeGenericType(userType), userStoreType);
}

Expand Down

0 comments on commit f19411e

Please sign in to comment.