Skip to content

Commit

Permalink
update swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
Haik committed Feb 22, 2024
1 parent 6535092 commit 48dccae
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/PandaWebApi.Tests/PandaWebApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Respawn" Version="6.2.0" />
<PackageReference Include="Respawn" Version="6.2.1" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.17.0.82934">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Testcontainers.PostgreSql" Version="3.7.0" />
<PackageReference Include="xunit" Version="2.6.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5">
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 0 additions & 2 deletions src/PandaWebApi/Attributes/AuthorizeAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Mvc.Filters;
using PandaWebApi.Contexts;
using PandaWebApi.DTOs.User;
using PandaWebApi.Enums;
using PandaWebApi.Services.Interfaces;
Expand Down
6 changes: 5 additions & 1 deletion src/PandaWebApi/Extensions/HangfireExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public static WebApplicationBuilder AddHangfireServer(this WebApplicationBuilder
configuration.UseRecommendedSerializerSettings();
configuration.UsePostgreSqlStorage(c => c.UseNpgsqlConnection(postgresConnectionString));
});
builder.Services.AddHangfireServer();

builder.Services.AddHangfireServer(options =>
{
options.WorkerCount = 5;
});
return builder;
}

Expand Down
4 changes: 2 additions & 2 deletions src/PandaWebApi/Models/UserToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class UserToken
public byte[] RefreshTokenHash { get; set; } = null!;
public DateTime AccessTokenExpiresAt { get; set; }
public DateTime RefreshTokenExpiresAt { get; set; }
public DateTime OriginalRefreshTokenCreatedAt { get; set; }
public DateTime InitialRefreshTokenCreatedAt { get; set; }
public DateTime CreatedAt { get; set; }
public User User { get; set; } = null!;

public UserToken PreviousUserToken { get; set; } = null!;
}
9 changes: 7 additions & 2 deletions src/PandaWebApi/PandaWebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.1.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="PandaTech.BaseConverter" Version="2.0.2" />
<PackageReference Include="Pandatech.Crypto" Version="2.2.3" />
<PackageReference Include="Pandatech.Crypto" Version="2.2.6" />
<PackageReference Include="PandaTech.FileExporter" Version="1.0.4" />
<PackageReference Include="PandaTech.IEnumerableFilters" Version="4.0.17" />
<PackageReference Include="Pandatech.PandaVaultClient" Version="3.0.5" />
<PackageReference Include="Pandatech.RegexBox" Version="1.1.4" />
<PackageReference Include="Pandatech.ResponseCrafter" Version="1.0.4" />
<PackageReference Include="PandaTech.ServiceResponse" Version="1.2.12" />
<PackageReference Include="RabbitMQ.Client" Version="6.8.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.17.0.82934">
Expand All @@ -60,5 +60,10 @@

<ItemGroup>
<_ContentIncludedByDefault Remove="be-tmp-web-api-postgres-logs\elastic-buffer-20230824.json" />
<_ContentIncludedByDefault Remove="wwwroot\assets\css\panda-style.css" />
<_ContentIncludedByDefault Remove="wwwroot\assets\images\favicon.svg" />
<_ContentIncludedByDefault Remove="wwwroot\assets\images\logo-wording.svg" />
<_ContentIncludedByDefault Remove="wwwroot\assets\images\logo.svg" />
<_ContentIncludedByDefault Remove="wwwroot\assets\js\docs.js" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions src/PandaWebApi/Services/Implementations/UserTokenService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task<UserToken> CreateTokenAsync(IdentifyUserDto user, HttpContext
RefreshTokenHash = Sha3.Hash(refreshTokenSignature),
AccessTokenExpiresAt = now.AddMinutes(AccessTokenExpirationMinutes),
RefreshTokenExpiresAt = now.AddMinutes(_refreshTokenExpirationMinutes),
OriginalRefreshTokenCreatedAt = now,
InitialRefreshTokenCreatedAt = now,
CreatedAt = now
};
await _context.UserTokens.AddAsync(token);
Expand Down Expand Up @@ -203,9 +203,9 @@ public async Task RefreshTokenAsync(RefreshTokenDto refreshTokenDto)

var newExpirationDate = now.AddMinutes(_refreshTokenExpirationMinutes);

if (newExpirationDate > userToken.OriginalRefreshTokenCreatedAt.AddMinutes(_refreshTokenMaxExpirationMinutes))
if (newExpirationDate > userToken.InitialRefreshTokenCreatedAt.AddMinutes(_refreshTokenMaxExpirationMinutes))
{
newExpirationDate = userToken.OriginalRefreshTokenCreatedAt.AddMinutes(_refreshTokenMaxExpirationMinutes);
newExpirationDate = userToken.InitialRefreshTokenCreatedAt.AddMinutes(_refreshTokenMaxExpirationMinutes);
}

if (newExpirationDate <= now.AddMinutes(60))
Expand All @@ -224,7 +224,7 @@ public async Task RefreshTokenAsync(RefreshTokenDto refreshTokenDto)
RefreshTokenHash = Sha3.Hash(newRefreshTokenSignature),
AccessTokenExpiresAt = now.AddMinutes(AccessTokenExpirationMinutes),
RefreshTokenExpiresAt = newExpirationDate,
OriginalRefreshTokenCreatedAt = userToken.OriginalRefreshTokenCreatedAt,
InitialRefreshTokenCreatedAt = userToken.InitialRefreshTokenCreatedAt,
CreatedAt = now
};

Expand Down
2 changes: 1 addition & 1 deletion src/PandaWebApi/wwwroot/assets/css/panda-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ div.topbar {
}

.swagger-ui .dialog-ux .modal-ux {
max-width: 300px;
max-width: 600px;
}

.opblock-summary-get:hover {
Expand Down
28 changes: 18 additions & 10 deletions src/PandaWebApi/wwwroot/assets/js/docs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
(function () {

var link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
document.head.removeChild(link);
link =
document.querySelector("link[rel*='icon']") ||
document.createElement("link");
document.addEventListener('DOMContentLoaded', function () {

var link = document.querySelector("link[rel*='icon']") || document.createElement("link");
document.head.removeChild(link);
link = document.createElement("link");
link.type = "image/x-icon";
link.rel = "shortcut icon";
link.href = "../assets/images/favicon.svg";
document.getElementsByTagName("head")[0].appendChild(link);
})();

// Adjusted MutationObserver code
const observer = new MutationObserver((mutations) => {
const modal = document.querySelector('.modal-ux-content');
if (modal) {
modal.scrollTo(0, 0);
observer.disconnect();
}
});

observer.observe(document.body, {
childList: true,
subtree: true,
});
});

0 comments on commit 48dccae

Please sign in to comment.