-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
daccf84
commit 5fe7f2a
Showing
36 changed files
with
1,063 additions
and
415 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/BlazorEcommerce.Application/Contracts/Identity/IAuthService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/BlazorEcommerce.Identity/Configurations/RoleConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using BlazorEcommerce.Shared.Constant; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace BlazorEcommerce.Identity.Configurations | ||
{ | ||
public class RoleConfiguration : IEntityTypeConfiguration<IdentityRole> | ||
{ | ||
public void Configure(EntityTypeBuilder<IdentityRole> builder) | ||
{ | ||
builder.HasData( | ||
new IdentityRole | ||
{ | ||
Id = "cac43a6e-f7bb-4448-baaf-1add431ccbbf", | ||
Name = "User", | ||
NormalizedName = "USER" | ||
}, | ||
new IdentityRole | ||
{ | ||
Id = "cbc43a8e-f7bb-4445-baaf-1add431ffbbf", | ||
Name = Constants.AdminRoleName, | ||
NormalizedName = Constants.AdminRoleName.ToUpper() | ||
} | ||
); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/BlazorEcommerce.Identity/Configurations/UserConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using BlazorEcommerce.Shared.Constant; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace BlazorEcommerce.Identity.Configurations | ||
{ | ||
public class UserConfiguration : IEntityTypeConfiguration<ApplicationUser> | ||
{ | ||
public void Configure(EntityTypeBuilder<ApplicationUser> builder) | ||
{ | ||
var hasher = new PasswordHasher<ApplicationUser>(); | ||
builder.HasData( | ||
new ApplicationUser | ||
{ | ||
Id = "8e445865-a24d-4543-a6c6-9443d048cdb9", | ||
Email = Constants.AdminEmail, | ||
NormalizedEmail = Constants.AdminEmail.ToUpper(), | ||
FirstName = "System", | ||
LastName = "Admin", | ||
UserName = Constants.AdminEmail, | ||
NormalizedUserName = Constants.AdminEmail.ToUpper(), | ||
PasswordHash = hasher.HashPassword(null, "Atharva@123"), | ||
EmailConfirmed = true | ||
} | ||
); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/BlazorEcommerce.Identity/Configurations/UserRoleConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
|
||
namespace BlazorEcommerce.Identity.Configurations | ||
{ | ||
public class UserRoleConfiguration : IEntityTypeConfiguration<IdentityUserRole<string>> | ||
{ | ||
public void Configure(EntityTypeBuilder<IdentityUserRole<string>> builder) | ||
{ | ||
builder.HasData( | ||
new IdentityUserRole<string> | ||
{ | ||
RoleId = "cbc43a8e-f7bb-4445-baaf-1add431ffbbf", | ||
UserId = "8e445865-a24d-4543-a6c6-9443d048cdb9" | ||
} | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/BlazorEcommerce.Identity/Contexts/ApiAuthorizationDbContext.cs
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/BlazorEcommerce.Identity/Contexts/ApplicationDbContext.cs
This file was deleted.
Oops, something went wrong.
94 changes: 0 additions & 94 deletions
94
src/BlazorEcommerce.Identity/Contexts/ApplicationDbContextInitialiser.cs
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
src/BlazorEcommerce.Identity/Contexts/UserIdentityDbContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace BlazorEcommerce.Identity.Contexts; | ||
|
||
public class UserIdentityDbContext : IdentityDbContext<ApplicationUser> | ||
{ | ||
public UserIdentityDbContext(DbContextOptions<UserIdentityDbContext> options) : base(options) | ||
{ | ||
} | ||
|
||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||
{ | ||
base.OnConfiguring(optionsBuilder); | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder builder) | ||
{ | ||
base.OnModelCreating(builder); | ||
|
||
builder.ApplyConfigurationsFromAssembly(typeof(UserIdentityDbContext).Assembly); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/BlazorEcommerce.Identity/Contexts/UserIdentityDbContextInitialiser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using BlazorEcommerce.Identity.Contexts; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace BlazorEcommerce.Persistence.Contexts; | ||
|
||
public class UserIdentityDbContextInitialiser | ||
{ | ||
private readonly UserIdentityDbContext _context; | ||
|
||
public UserIdentityDbContextInitialiser(UserIdentityDbContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public async Task InitialiseAsync() | ||
{ | ||
await InitialiseWithMigrationsAsync(); | ||
} | ||
|
||
private async Task InitialiseWithMigrationsAsync() | ||
{ | ||
if (_context.Database.IsSqlServer()) | ||
{ | ||
await _context.Database.MigrateAsync(); | ||
} | ||
else | ||
{ | ||
await _context.Database.EnsureCreatedAsync(); | ||
} | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.