diff options
Diffstat (limited to 'src/server/IdentityServer/ProfileService.cs')
| -rw-r--r-- | src/server/IdentityServer/ProfileService.cs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/server/IdentityServer/ProfileService.cs b/src/server/IdentityServer/ProfileService.cs index 197086c..0c14dd5 100644 --- a/src/server/IdentityServer/ProfileService.cs +++ b/src/server/IdentityServer/ProfileService.cs @@ -1,8 +1,11 @@ -using System.Reflection; +using System; +using System.Collections.Generic; +using System.Security.Claims; using System.Threading.Tasks; +using Dough.Models; using Dough.Models.Database; using Dough.Utilities; -using IdentityServer4; +using IdentityModel; using IdentityServer4.Models; using IdentityServer4.Services; @@ -17,14 +20,24 @@ namespace Dough.IdentityServer _context = context; } - public Task GetProfileDataAsync(ProfileDataRequestContext context) + public async Task GetProfileDataAsync(ProfileDataRequestContext context) { - throw new System.NotImplementedException(); + var userId = context.Subject.GetClaimValueOrDefault(JwtClaimTypes.Subject)?.ToGuidOrDefault(); + if (userId == default) return; + var user = _context.Users.SingleOrDefault((Guid) userId); + var claims = new List<Claim> + { + new Claim(JwtClaimTypes.PreferredUserName, user.Username) + }; + context.AddRequestedClaims(claims); } - public Task IsActiveAsync(IsActiveContext context) + public async Task IsActiveAsync(IsActiveContext context) { - return default; + var userId = context.Subject.GetClaimValueOrDefault(JwtClaimTypes.Subject)?.ToGuidOrDefault(); + if (userId == default) return; + var user = _context.Users.SingleOrDefault((Guid) userId); + context.IsActive = !user.Hidden; } } }
\ No newline at end of file |
