diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2020-08-11 21:16:02 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2020-08-11 21:16:02 +0200 |
| commit | a5f1018fda5572912c126b1e8dd656209fca0e46 (patch) | |
| tree | 8e6ae53e8f190bad395dc8c974c41ab376889a9e /src/server/IdentityServer/ProfileService.cs | |
| parent | 69854dca474bf73eec9f8fcbf20f328e4453c8cf (diff) | |
| download | dough-a5f1018fda5572912c126b1e8dd656209fca0e46.tar.xz dough-a5f1018fda5572912c126b1e8dd656209fca0e46.zip | |
persisted grants
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 |
