Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions source/EasyWay.WebApi/Internals/Contexts/UserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ internal sealed class UserContext : IUserContext
{
public UserContext(IHttpContextAccessor httpContextAccessor)
{
var userId = httpContextAccessor
UserId = httpContextAccessor
.HttpContext?
.User?
.Claims?
.SingleOrDefault(x => x.Type == "sub")?
.Value;

UserId = userId is null ? null : new Guid(userId);
}

public Guid? UserId { get; }
public string? UserId { get; }

public bool IsAuthenticated => UserId is not null;
}
Expand Down
2 changes: 1 addition & 1 deletion source/EasyWay/IUserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public interface IUserContext
{
Guid? UserId { get; }
string? UserId { get; }

bool IsAuthenticated { get; }
}
Expand Down
4 changes: 2 additions & 2 deletions source/EasyWay/Internals/Contexts/DefaultUserContext.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace EasyWay.Internals.Contexts
{
internal class DefaultUserContext : IUserContext
internal sealed class DefaultUserContext : IUserContext
{
public Guid? UserId => null;
public string? UserId => null;

public bool IsAuthenticated => false;
}
Expand Down
Loading