diff --git a/AnalysisData/AnalysisData/AnalysisData.csproj b/AnalysisData/AnalysisData/AnalysisData.csproj
index 065f993..fe1cb9e 100644
--- a/AnalysisData/AnalysisData/AnalysisData.csproj
+++ b/AnalysisData/AnalysisData/AnalysisData.csproj
@@ -15,9 +15,10 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
-
+
diff --git a/AnalysisData/AnalysisData/Data/ApplicationDbContext.cs b/AnalysisData/AnalysisData/Data/ApplicationDbContext.cs
index cd6f64f..cc75498 100644
--- a/AnalysisData/AnalysisData/Data/ApplicationDbContext.cs
+++ b/AnalysisData/AnalysisData/Data/ApplicationDbContext.cs
@@ -13,8 +13,5 @@ public ApplicationDbContext(DbContextOptions options)
public DbSet Users { get; set; }
public DbSet Roles { get; set; }
public DbSet UserRoles { get; set; }
-
- // public DbSet SystemManagers { get; set; }
- // public DbSet DataManagers { get; set; }
- // public DbSet DataAnalysts { get; set; }
+
}
\ No newline at end of file
diff --git a/AnalysisData/AnalysisData/JwtService/JwtService.cs b/AnalysisData/AnalysisData/JwtService/JwtService.cs
index b8b2d4e..fc31a45 100644
--- a/AnalysisData/AnalysisData/JwtService/JwtService.cs
+++ b/AnalysisData/AnalysisData/JwtService/JwtService.cs
@@ -28,23 +28,17 @@ public async Task GenerateJwtToken(string userName)
var claims = new List
{
new Claim(ClaimTypes.Name, userName),
- new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
};
-
- Console.WriteLine("sadsada");
foreach (var role in roles)
{
- var result = _roleRepository.GetRoles(role.Role.Id);
- claims.Add(new Claim(ClaimTypes.Role, result.Result.RoleName));
+ var result = await _roleRepository.GetRoles(role.Id);
+ claims.Add(new Claim(ClaimTypes.Role, result.RoleName));
}
-
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["Jwt:Key"]));
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
-
+
var token = new JwtSecurityToken(
- issuer: _configuration["Jwt:Issuer"],
- audience: _configuration["Jwt:Audience"],
claims: claims,
expires: DateTime.Now.AddMinutes(30),
signingCredentials: creds);
diff --git a/AnalysisData/AnalysisData/Migrations/20240812154524_InitialCreate.Designer.cs b/AnalysisData/AnalysisData/Migrations/20240812200637_InitialCreate.Designer.cs
similarity index 98%
rename from AnalysisData/AnalysisData/Migrations/20240812154524_InitialCreate.Designer.cs
rename to AnalysisData/AnalysisData/Migrations/20240812200637_InitialCreate.Designer.cs
index 44df159..051ab95 100644
--- a/AnalysisData/AnalysisData/Migrations/20240812154524_InitialCreate.Designer.cs
+++ b/AnalysisData/AnalysisData/Migrations/20240812200637_InitialCreate.Designer.cs
@@ -11,7 +11,7 @@
namespace AnalysisData.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
- [Migration("20240812154524_InitialCreate")]
+ [Migration("20240812200637_InitialCreate")]
partial class InitialCreate
{
///
diff --git a/AnalysisData/AnalysisData/Migrations/20240812154524_InitialCreate.cs b/AnalysisData/AnalysisData/Migrations/20240812200637_InitialCreate.cs
similarity index 100%
rename from AnalysisData/AnalysisData/Migrations/20240812154524_InitialCreate.cs
rename to AnalysisData/AnalysisData/Migrations/20240812200637_InitialCreate.cs
diff --git a/AnalysisData/AnalysisData/Program.cs b/AnalysisData/AnalysisData/Program.cs
index b59b154..e2c417b 100644
--- a/AnalysisData/AnalysisData/Program.cs
+++ b/AnalysisData/AnalysisData/Program.cs
@@ -28,6 +28,7 @@
app.UseHttpsRedirection();
app.UseRouting();
+app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();
\ No newline at end of file
diff --git a/AnalysisData/AnalysisData/UserRepositories/UserRepository.cs b/AnalysisData/AnalysisData/UserRepositories/UserRepository.cs
index fbf59a1..3ce6b4f 100644
--- a/AnalysisData/AnalysisData/UserRepositories/UserRepository.cs
+++ b/AnalysisData/AnalysisData/UserRepositories/UserRepository.cs
@@ -18,7 +18,7 @@ public UserRepository(ApplicationDbContext context)
public async Task GetUser(string userName)
{
- var test = await _context.Users.SingleOrDefaultAsync(x => x.Username == userName);
+ var test = await _context.Users.Include(u=> u.UserRoles).SingleOrDefaultAsync(x => x.Username == userName);
return test;
}
diff --git a/AnalysisData/AnalysisData/appsettings.json b/AnalysisData/AnalysisData/appsettings.json
index b2d67a4..e933368 100644
--- a/AnalysisData/AnalysisData/appsettings.json
+++ b/AnalysisData/AnalysisData/appsettings.json
@@ -1,4 +1,9 @@
{
+ "Jwt": {
+ "CookieName" : "jwt",
+ "Key": "haskdhkashdsahdakjdhlkhdfkljshflkasz.ncv,mnz,m.cnvz.alsjdfla;aewfj;a;djf",
+ "ExpireMinutes": 60
+ },
"Logging": {
"LogLevel": {
"Default": "Information",
@@ -6,7 +11,8 @@
}
},
"ConnectionStrings": {
- "DefaultConnection": "Host=localhost;Database=MohaymenProject;Username=postgres;Password=mahdijm"
+ "DefaultConnection": "Host=localhost;Database=mohaymen;Username=postgres;Password=mahdijm;Timeout=300"
},
+
"AllowedHosts": "*"
}