Skip to content

Commit

Permalink
Add custome stores
Browse files Browse the repository at this point in the history
  • Loading branch information
dev.soheilalizadeh committed Dec 17, 2018
1 parent 8db762e commit b86275d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
14 changes: 14 additions & 0 deletions App/Services/Identity/Stores/AppRoleStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using App.Data;
using App.Domain.Identity;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

namespace App.Services.Identity.Stores
{
public class AppRoleStore : RoleStore<Role,ApplicationDbContext,int,UserRole,RoleClaim>
{
public AppRoleStore(ApplicationDbContext context, IdentityErrorDescriber describer = null) : base(context, describer)
{
}
}
}
17 changes: 17 additions & 0 deletions App/Services/Identity/Stores/AppUserStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using App.Data;
using App.Domain.Identity;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

namespace App.Services.Identity.Stores
{
public class AppUserStore : UserStore<User,Role,ApplicationDbContext,int,UserClaim,UserRole,UserLogin,UserToken,RoleClaim>
{
public AppUserStore(ApplicationDbContext context, IdentityErrorDescriber describer = null) : base(context, describer)
{
}
}
}
6 changes: 5 additions & 1 deletion App/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using App.Data;
using App.Domain;
using App.Domain.Identity;
using App.Services.Identity.Stores;
using App.Services.Identity.Validators;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -52,7 +55,8 @@ public void ConfigureServices(IServiceCollection services)
option.SignIn.RequireConfirmedEmail = true;
})
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddUserStore<AppUserStore>()
.AddRoleStore<AppRoleStore>()
.AddDefaultTokenProviders();

}
Expand Down

0 comments on commit b86275d

Please sign in to comment.