Skip to content

Commit

Permalink
samples/IdentitySample.Mvc: use ServiceCollectionExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
miltador committed Mar 9, 2017
1 parent 05204be commit 0b0ed26
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions samples/IdentitySample.Mvc/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Security.Claims;
using System.Threading.Tasks;
Expand Down Expand Up @@ -60,13 +60,10 @@ public void ConfigureServices(IServiceCollection services)
{
services.Configure<DynamoDbSettings>(Configuration.GetSection("DynamoDB"));

services.AddSingleton<DynamoRoleUsersStore<DynamoIdentityRole, DynamoIdentityUser>>();
services.AddSingleton<IUserStore<DynamoIdentityUser>>(sp =>
{
var roleUsersStore = sp.GetService<DynamoRoleUsersStore<DynamoIdentityRole, DynamoIdentityUser>>();
return new DynamoUserStore<DynamoIdentityUser, DynamoIdentityRole>(roleUsersStore);
});
services.AddSingleton<IRoleClaimStore<DynamoIdentityRole>>(sp => new DynamoRoleStore<DynamoIdentityRole>());
services.AddDynamoDBIdentity<DynamoIdentityUser, DynamoIdentityRole>()
.AddUserStore()
.AddRoleStore()
.AddRoleUsersStore();

services.Configure<IdentityOptions>(options =>
{
Expand Down Expand Up @@ -165,7 +162,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
.GetService<IUserStore<DynamoIdentityUser>>()
as DynamoUserStore<DynamoIdentityUser, DynamoIdentityRole>;
var roleStore = app.ApplicationServices
.GetService<IRoleClaimStore<DynamoIdentityRole>>()
.GetService<IRoleStore<DynamoIdentityRole>>()
as DynamoRoleStore<DynamoIdentityRole>;
var roleUsersStore = app.ApplicationServices
.GetService<DynamoRoleUsersStore<DynamoIdentityRole, DynamoIdentityUser>>();
Expand Down Expand Up @@ -204,7 +201,7 @@ public UserClaimsPrincipalFactory(
{
throw new ArgumentNullException(nameof(userManager));
}
if (optionsAccessor == null || optionsAccessor.Value == null)
if (optionsAccessor?.Value == null)
{
throw new ArgumentNullException(nameof(optionsAccessor));
}
Expand Down

0 comments on commit 0b0ed26

Please sign in to comment.