-
Notifications
You must be signed in to change notification settings - Fork 1
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
e11597e
commit e114e28
Showing
28 changed files
with
1,844 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
@page "/login" | ||
|
||
<PageTitle>Login</PageTitle> | ||
|
||
<h3>Login</h3> | ||
@if (string.IsNullOrEmpty(Message) == false) | ||
{ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ main { | |
} | ||
|
||
.sidebar { | ||
width: 250px; | ||
width: 290px; | ||
height: 100vh; | ||
position: sticky; | ||
top: 0; | ||
|
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
25 changes: 25 additions & 0 deletions
25
HR.LeaveManagement.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,25 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace HR.LeaveManagement.Identity.Configurations; | ||
public class RoleConfiguration : IEntityTypeConfiguration<IdentityRole> | ||
{ | ||
public void Configure(EntityTypeBuilder<IdentityRole> builder) | ||
{ | ||
builder.HasData( | ||
new IdentityRole | ||
{ | ||
Id = "cac43a6e-f7bb-4448-baaf-1add431ccbbf", | ||
Name = "Employee", | ||
NormalizedName = "EMPLOYEE" | ||
}, | ||
new IdentityRole | ||
{ | ||
Id = "cbc43a8e-f7bb-4445-baaf-1add431ffbbf", | ||
Name = "Administrator", | ||
NormalizedName = "ADMINISTRATOR" | ||
} | ||
); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
HR.LeaveManagement.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,40 @@ | ||
using HR.LeaveManagement.Identity.Models; | ||
|
||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace HR.LeaveManagement.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 = "[email protected]", | ||
NormalizedEmail = "[email protected]", | ||
FirstName = "System", | ||
LastName = "Admin", | ||
UserName = "[email protected]", | ||
NormalizedUserName = "[email protected]", | ||
PasswordHash = hasher.HashPassword(null, "P@ssword1"), | ||
EmailConfirmed = true | ||
}, | ||
new ApplicationUser | ||
{ | ||
Id = "9e224968-33e4-4652-b7b7-8574d048cdb9", | ||
Email = "[email protected]", | ||
NormalizedEmail = "[email protected]", | ||
FirstName = "System", | ||
LastName = "User", | ||
UserName = "[email protected]", | ||
NormalizedUserName = "[email protected]", | ||
PasswordHash = hasher.HashPassword(null, "P@ssword1"), | ||
EmailConfirmed = true | ||
} | ||
); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
HR.LeaveManagement.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,23 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace HR.LeaveManagement.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" | ||
}, | ||
new IdentityUserRole<string> | ||
{ | ||
RoleId = "cac43a6e-f7bb-4448-baaf-1add431ccbbf", | ||
UserId = "9e224968-33e4-4652-b7b7-8574d048cdb9" | ||
} | ||
); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
HR.LeaveManagement.Identity/DbContext/HrLeaveManagementIdentityDbContext.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,19 @@ | ||
using HR.LeaveManagement.Identity.Models; | ||
|
||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace HR.LeaveManagement.Identity.DbContext; | ||
public class HrLeaveManagementIdentityDbContext : IdentityDbContext<ApplicationUser> | ||
{ | ||
public HrLeaveManagementIdentityDbContext(DbContextOptions<HrLeaveManagementIdentityDbContext> options) | ||
: base(options) | ||
{ | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder builder) | ||
{ | ||
base.OnModelCreating(builder); | ||
builder.ApplyConfigurationsFromAssembly(typeof(HrLeaveManagementIdentityDbContext).Assembly); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
HR.LeaveManagement.Identity/HR.LeaveManagement.Identity.csproj
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,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.5" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.5" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\HR.LeaveManagement.Application\HR.LeaveManagement.Application.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
54 changes: 54 additions & 0 deletions
54
HR.LeaveManagement.Identity/IdentityServicesRegistration.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,54 @@ | ||
using System.Text; | ||
|
||
using HR.LeaveManagement.Application.Contracts.Identity; | ||
using HR.LeaveManagement.Application.Models.Identity; | ||
using HR.LeaveManagement.Identity.DbContext; | ||
using HR.LeaveManagement.Identity.Models; | ||
using HR.LeaveManagement.Identity.Services; | ||
|
||
using Microsoft.AspNetCore.Authentication.JwtBearer; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.IdentityModel.Tokens; | ||
|
||
namespace HR.LeaveManagement.Identity; | ||
public static class IdentityServicesRegistration | ||
{ | ||
public static IServiceCollection AddIdentityServices(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.Configure<JwtSettings>(configuration.GetSection("JwtSettings")); | ||
|
||
services.AddDbContext<HrLeaveManagementIdentityDbContext>(options => | ||
options.UseSqlServer(configuration.GetConnectionString("HrDatabaseConnectionString"))); | ||
|
||
services.AddIdentity<ApplicationUser, IdentityRole>() | ||
.AddEntityFrameworkStores<HrLeaveManagementIdentityDbContext>().AddDefaultTokenProviders(); | ||
|
||
services.AddTransient<IAuthService, AuthService>(); | ||
services.AddTransient<IUserService, UserService>(); | ||
|
||
services.AddAuthentication(options => | ||
{ | ||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; | ||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; | ||
}).AddJwtBearer(o => | ||
{ | ||
o.TokenValidationParameters = new TokenValidationParameters | ||
{ | ||
ValidateIssuerSigningKey = true, | ||
ValidateIssuer = true, | ||
ValidateAudience = true, | ||
ValidateLifetime = true, | ||
ClockSkew = TimeSpan.Zero, | ||
ValidIssuer = configuration["JwtSettings:Issuer"], | ||
ValidAudience = configuration["JwtSettings:Audience"], | ||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["JwtSettings:Key"])) | ||
|
||
}; | ||
}); | ||
|
||
return services; | ||
} | ||
} |
Oops, something went wrong.