Skip to content

Commit

Permalink
Merge pull request #93 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
Fix stacktrace and make logs better
  • Loading branch information
Ali-YousefiTelori authored Dec 6, 2023
2 parents df9e199 + 9a5c622 commit 1d013ec
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async Task<MessageContract<bool>> HasPermission(HttpContext httpContext)
string actionName = httpContext.Request.RouteValues["action"].ToString();
List<Claim> roleClaims = httpContext.User.FindAll(ClaimTypes.Role).ToList();
if (roleClaims.Count == 0)
return (FailedReasonType.AccessDenied, "There is no claim role founded! did you forgot to use services.AddAuthentication? or did you set Bearer for authorize?");
return (FailedReasonType.AccessDenied, $"There is no claim role founded! did you forgot to use services.AddAuthentication? or did you set Bearer for authorize? controllerName: {controllerName} actionName: {actionName}");
if (!roleClaims.All(x => CachedPermissions.ContainsKey(x.Value)))
{
foreach (var role in roleClaims)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.61</Version>
<Version>0.0.0.62</Version>
<Description>asp core servces.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,services,asp,aspnet</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.61</Version>
<Version>0.0.0.62</Version>
<Description>asp core servces.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,services,asp,aspnet,aspcore,efcore</PackageTags>
Expand All @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="EasyMicroservices.Mapper.CompileTimeMapper" Version="0.0.0.6" />
<PackageReference Include="EasyMicroservices.Serialization.Newtonsoft.Json" Version="0.0.0.6" />
<PackageReference Include="EasyMicroservices.Serialization.Newtonsoft.Json" Version="0.0.0.8" />
<PackageReference Include="EasyMicroservices.Mapper.SerializerMapper" Version="0.0.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="EasyMicroservices.WhiteLabelsMicroservice.Clients" Version="0.0.0.11" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ internal static Task ExceptionHandler(HttpContext context, Exception exception)
{
context.Response.ContentType = MediaTypeNames.Application.Json;
context.Response.StatusCode = (int)HttpStatusCode.OK;
MessageContract response = exception is InvalidResultOfMessageContractException ex ? ex.MessageContract : exception;
MessageContract response;
if (exception is InvalidResultOfMessageContractException ex)
{
response = ex.MessageContract;
response.Error.StackTrace.Add(ex.Message);
response.Error.StackTrace.AddRange(ex.StackTrace.ToListStackTrace());
}
else
response = exception;
if (exception.Message.Contains("Authenti", StringComparison.OrdinalIgnoreCase) && response.Error.FailedReasonType != FailedReasonType.AccessDenied)
response.Error.FailedReasonType = FailedReasonType.SessionAccessDenied;
response.Error.ServiceDetails.MethodName = context.Request.Path.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.61</Version>
<Version>0.0.0.62</Version>
<Description>core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,client,clients</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.61</Version>
<Version>0.0.0.62</Version>
<Description>core contracts.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,contract,contracts,dto,dtos</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.61</Version>
<Version>0.0.0.62</Version>
<Description>core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database</PackageTags>
Expand All @@ -19,7 +19,7 @@
<ItemGroup>
<PackageReference Include="EasyMicroservices.Database" Version="0.0.0.17" />
<PackageReference Include="EasyMicroservices.Mapper" Version="0.0.0.5" />
<PackageReference Include="EasyMicroservices.ServiceContracts" Version="0.0.0.20" />
<PackageReference Include="EasyMicroservices.ServiceContracts" Version="0.0.0.21" />
<PackageReference Include="EasyMicroservices.Utilities" Version="0.0.0.13" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.61</Version>
<Version>0.0.0.62</Version>
<Description>ef core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,ef,efcore</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.61</Version>
<Version>0.0.0.62</Version>
<Description>ef core of Relational database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,ef,efcore,Relational</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="EasyMicroservices.Laboratory" Version="0.0.0.15" />
<PackageReference Include="EasyMicroservices.Mapper.CompileTimeMapper" Version="0.0.0.6" />
<PackageReference Include="EasyMicroservices.Mapper.SerializerMapper" Version="0.0.0.3" />
<PackageReference Include="EasyMicroservices.Serialization.Newtonsoft.Json" Version="0.0.0.6" />
<PackageReference Include="EasyMicroservices.Serialization.Newtonsoft.Json" Version="0.0.0.8" />
<PackageReference Include="EasyMicroservices.Tests" Version="0.0.0.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
Expand Down

0 comments on commit 1d013ec

Please sign in to comment.