-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from sj-distributor/dotnet9
Upgrade to dotnet9
- Loading branch information
Showing
92 changed files
with
884 additions
and
1,266 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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,14 @@ | ||
// Global using directives | ||
|
||
global using Autofac; | ||
global using Mediator.Net; | ||
global using Microsoft.AspNetCore.Mvc; | ||
global using Serilog; | ||
global using Wax.Api.Extensions; | ||
global using Wax.Api.Models; | ||
global using Wax.Core; | ||
global using Wax.Core.Commands.Customers; | ||
global using Wax.Core.Requests; | ||
global using Wax.Core.Requests.Customers; | ||
global using Wax.Infrastructure; | ||
global using ILogger = Serilog.ILogger; |
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,8 @@ | ||
namespace Wax.Api.Models; | ||
|
||
public class UpdateCustomerModel | ||
{ | ||
public string Name { get; set; } | ||
public string Contact { get; set; } | ||
public string Address { get; set; } | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Security.Claims; | ||
|
||
namespace Wax.Api; | ||
|
||
public class UserContext : IUserContext | ||
{ | ||
private readonly IHttpContextAccessor _httpContextAccessor; | ||
|
||
private string _cachedUserId; | ||
|
||
public UserContext(IHttpContextAccessor httpContextAccessor) | ||
{ | ||
_httpContextAccessor = httpContextAccessor; | ||
} | ||
|
||
public string GetCurrentUserId() | ||
{ | ||
if (!string.IsNullOrEmpty(_cachedUserId)) | ||
{ | ||
return _cachedUserId; | ||
} | ||
|
||
SetCurrentUserId(); | ||
|
||
return _cachedUserId; | ||
} | ||
|
||
public void SetCurrentUserId(string userId = null) | ||
{ | ||
if (userId == null) | ||
{ | ||
var user = _httpContextAccessor.HttpContext?.User; | ||
if (user is null) | ||
{ | ||
throw new InvalidOperationException("HttpContext must be present to inspect auth info."); | ||
} | ||
|
||
var userIdClaim = user.FindFirst("sub") ?? user.FindFirst(ClaimTypes.NameIdentifier); | ||
if (userIdClaim is null) | ||
{ | ||
throw new InvalidOperationException("User Id was not present in the request token."); | ||
} | ||
|
||
_cachedUserId = userIdClaim.Value; | ||
} | ||
else | ||
{ | ||
_cachedUserId = userId; | ||
} | ||
} | ||
} |
Oops, something went wrong.