Skip to content

Commit

Permalink
Upgrade to SDK-7.0.305
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed Jul 7, 2023
1 parent da3b276 commit 96c4161
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "7.0.3",
"version": "7.0.8",
"commands": [
"dotnet-ef"
]
Expand Down
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dotnet_diagnostic.CA5395.severity = suggestion
dotnet_diagnostic.CA1510.severity = suggestion
dotnet_diagnostic.S4487.severity = suggestion
dotnet_diagnostic.S1144.severity = suggestion
dotnet_diagnostic.S6605.severity = suggestion

# CA1852: Type can be sealed because it has no subtypes in its containing assembly and is not externally visible
dotnet_diagnostic.CA1852.severity = suggestion
Expand Down
12 changes: 0 additions & 12 deletions .github/FUNDING.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.203
dotnet-version: 7.0.305
- name: Build DNTIdentity
run: dotnet build ./src/ASPNETCoreIdentitySample/ASPNETCoreIdentitySample.csproj --configuration Release
40 changes: 20 additions & 20 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
<Project>
<ItemGroup>
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.50" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.5.22" />
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.63" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.6.40" />
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="AsyncFixer" Version="1.6.0" />
<PackageVersion Include="Asyncify" Version="0.9.7" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.0.0.68202" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.4.0.72892" />
<PackageVersion Include="SecurityCodeScan.VS2019" Version="5.6.7" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.3.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Analyzers" Version="7.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.8" />
<PackageVersion Include="DNTBreadCrumb.Core" Version="1.9.3" />
<PackageVersion Include="DNTCaptcha.Core" Version="4.6.0" />
<PackageVersion Include="DNTCaptcha.Core" Version="4.7.2" />
<PackageVersion Include="DNTCommon.Web.Core" Version="3.5.2" />
<PackageVersion Include="System.Drawing.Common" Version="7.0.0" />
<PackageVersion Include="DNTPersianUtils.Core" Version="5.6.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.8" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.3" />
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="7.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.8" />
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="7.0.8" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageVersion Include="MSTest.TestFramework" Version="3.0.2" />
<PackageVersion Include="Microsoft.Extensions.Caching.SqlServer" Version="7.0.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.0.4" />
<PackageVersion Include="MSTest.TestFramework" Version="3.0.4" />
<PackageVersion Include="Microsoft.Extensions.Caching.SqlServer" Version="7.0.8" />
<PackageVersion Include="cloudscribe.Web.Pagination" Version="6.0.0" />
<PackageVersion Include="LigerShark.WebOptimizer.Core" Version="3.0.384" />
<PackageVersion Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div dir="rtl">

# سفارشی سازی ASP.NET Core Identity SDK-7.0.200
# سفارشی سازی ASP.NET Core Identity SDK-7.0.305

<p>
<a href="https://github.com/VahidN/DNTIdentity">
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.203",
"version": "7.0.305",
"rollForward": "latestMajor",
"allowPrerelease": false
}
Expand Down
5 changes: 3 additions & 2 deletions src/ASPNETCoreIdentitySample.Common/WebToolkit/ServerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ public static string GetAppDataFolderPath()
{
Directory.CreateDirectory(appDataFolderPath);
}

return appDataFolderPath;
}

public static string GetWwwRootPath()
{
return Path.Combine(
AppContext.BaseDirectory.Split(new[] { "bin" }, StringSplitOptions.RemoveEmptyEntries).First(),
"wwwroot");
AppContext.BaseDirectory.Split(new[] { "bin" }, StringSplitOptions.RemoveEmptyEntries)[0],
"wwwroot");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c_%%a_%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME: =0%") do (set mytime=%%a%%b)
dotnet tool update --global dotnet-ef --version 7.0.3
dotnet tool update --global dotnet-ef --version 7.0.8
dotnet tool restore
dotnet build
dotnet ef migrations --startup-project ../ASPNETCoreIdentitySample/ add V%mydate%_%mytime% --context MsSqlDbContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dotnet tool update --global dotnet-ef --version 7.0.3
dotnet tool update --global dotnet-ef --version 7.0.8
dotnet tool restore
dotnet build
dotnet ef --startup-project ../ASPNETCoreIdentitySample/ database update --context MsSqlDbContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c_%%a_%%b)
For /f "tokens=1-2 delims=/:" %%a in ("%TIME: =0%") do (set mytime=%%a%%b)
dotnet tool update --global dotnet-ef --version 7.0.3
dotnet tool update --global dotnet-ef --version 7.0.8
dotnet tool restore
dotnet build
dotnet ef migrations --startup-project ../ASPNETCoreIdentitySample/ add V%mydate%_%mytime% --context SQLiteDbContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dotnet tool update --global dotnet-ef --version 7.0.3
dotnet tool update --global dotnet-ef --version 7.0.8
dotnet tool restore
dotnet build
dotnet ef --startup-project ../ASPNETCoreIdentitySample/ database update --context SQLiteDbContext
Expand Down
36 changes: 18 additions & 18 deletions src/ASPNETCoreIdentitySample.Services/Identity/SiteStatService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public Task<List<User>> GetOnlineUsersListAsync(int numbersToTake, int minutesTo
var now = DateTime.UtcNow;
var minutes = now.AddMinutes(-minutesToTake);
return _users.AsNoTracking()
.Where(user => user.LastVisitDateTime != null && user.LastVisitDateTime.Value <= now
&& user.LastVisitDateTime.Value >= minutes)
.OrderByDescending(user => user.LastVisitDateTime)
.Take(numbersToTake)
.ToListAsync();
.Where(user => user.LastVisitDateTime != null && user.LastVisitDateTime.Value <= now
&& user.LastVisitDateTime.Value >= minutes)
.OrderByDescending(user => user.LastVisitDateTime)
.Take(numbersToTake)
.ToListAsync();
}

public Task<List<User>> GetTodayBirthdayListAsync()
Expand All @@ -41,18 +41,18 @@ public Task<List<User>> GetTodayBirthdayListAsync()
var day = now.Day;
var month = now.Month;
return _users.AsNoTracking()
.Where(user => user.BirthDate != null && user.IsActive
&& user.BirthDate.Value.Day == day
&& user.BirthDate.Value.Month == month)
.ToListAsync();
.Where(user => user.BirthDate != null && user.IsActive
&& user.BirthDate.Value.Day == day
&& user.BirthDate.Value.Month == month)
.ToListAsync();
}

public async Task<AgeStatViewModel> GetUsersAverageAge()
{
var users = await _users.AsNoTracking()
.Where(x => x.BirthDate != null && x.IsActive)
.OrderBy(x => x.BirthDate)
.ToListAsync();
.Where(x => x.BirthDate != null && x.IsActive)
.OrderBy(x => x.BirthDate)
.ToListAsync();

var count = users.Count;
if (count == 0)
Expand All @@ -63,12 +63,12 @@ public async Task<AgeStatViewModel> GetUsersAverageAge()
var sum = users.Where(user => user.BirthDate != null).Sum(user => (int?)user.BirthDate.Value.GetAge()) ?? 0;

return new AgeStatViewModel
{
AverageAge = sum / count,
MaxAgeUser = users.First(),
MinAgeUser = users.Last(),
UsersCount = count
};
{
AverageAge = sum / count,
MaxAgeUser = users[0],
MinAgeUser = users[^1],
UsersCount = count,
};
}

public async Task UpdateUserLastVisitDateTimeAsync(ClaimsPrincipal claimsPrincipal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ public async Task AddToUsedPasswordsListAsync(User user)
}

await _userUsedPasswords.AddAsync(new UserUsedPassword
{
UserId = user.Id,
HashedPassword = user.PasswordHash
});
{
UserId = user.Id,
HashedPassword = user.PasswordHash,
});
await _uow.SaveChangesAsync();
}

public async Task<DateTime?> GetLastUserPasswordChangeDateAsync(int userId)
{
var lastPasswordHistory =
await _userUsedPasswords //.AsNoTracking() --> removes shadow properties
.OrderByDescending(userUsedPassword => userUsedPassword.Id)
.FirstOrDefaultAsync(userUsedPassword => userUsedPassword.UserId == userId);
.OrderByDescending(userUsedPassword => userUsedPassword.Id)
.FirstOrDefaultAsync(userUsedPassword => userUsedPassword.UserId == userId);
if (lastPasswordHistory == null)
{
return null;
Expand Down Expand Up @@ -97,14 +97,14 @@ public async Task<bool> IsPreviouslyUsedPasswordAsync(User user, string newPassw

var userId = user.Id;
var usedPasswords = await _userUsedPasswords
.AsNoTracking()
.Where(userUsedPassword => userUsedPassword.UserId == userId)
.OrderByDescending(userUsedPassword => userUsedPassword.Id)
.Select(userUsedPassword => userUsedPassword.HashedPassword)
.Take(_notAllowedPreviouslyUsedPasswords)
.ToListAsync();
return usedPasswords.Any(hashedPassword =>
_passwordHasher.VerifyHashedPassword(user, hashedPassword, newPassword) !=
PasswordVerificationResult.Failed);
.AsNoTracking()
.Where(userUsedPassword => userUsedPassword.UserId == userId)
.OrderByDescending(userUsedPassword => userUsedPassword.Id)
.Select(userUsedPassword => userUsedPassword.HashedPassword)
.Take(_notAllowedPreviouslyUsedPasswords)
.ToListAsync();
return usedPasswords.Exists(hashedPassword =>
_passwordHasher.VerifyHashedPassword(user, hashedPassword, newPassword) !=
PasswordVerificationResult.Failed);
}
}
6 changes: 3 additions & 3 deletions src/ASPNETCoreIdentitySample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

var builder = WebApplication.CreateBuilder(args);
ConfigureLogging(builder.Logging, builder.Environment, builder.Configuration);
ConfigureServices(builder.Services, builder.Configuration);
ConfigureServices(builder.Services, builder.Configuration, builder.Environment);
var webApp = builder.Build();
ConfigureMiddlewares(webApp, webApp.Environment);
ConfigureEndpoints(webApp);
ConfigureDatabase(webApp);
webApp.Run();

void ConfigureServices(IServiceCollection services, IConfiguration configuration)
void ConfigureServices(IServiceCollection services, IConfiguration configuration, IWebHostEnvironment env)
{
services.Configure<SiteSettings>(options => configuration.Bind(options));
services.Configure<ContentSecurityPolicyConfig>(options =>
Expand All @@ -30,8 +30,8 @@ void ConfigureServices(IServiceCollection services, IConfiguration configuration
{
options.UseCookieStorageProvider()
.AbsoluteExpiration(7)
.ShowExceptionsInResponse(env.IsDevelopment())
.ShowThousandsSeparators(false)
.WithNoise(25, 3)
.WithEncryptionKey("This is my secure key!");
});
services.AddCloudscribePagination();
Expand Down

0 comments on commit 96c4161

Please sign in to comment.