Adds user Alias. Make StoredDataUrls optionals.

This commit is contained in:
Jonathan Bourdon
2024-07-22 00:42:27 -04:00
parent 8551398edc
commit 0faf5a9a0e
31 changed files with 1720 additions and 174 deletions

View File

@@ -12,10 +12,11 @@ public static class JwtTokenHelper
string issuer,
string audience,
string key,
string? userId,
string? email,
string? firstname,
string? lastname,
string userId,
string email,
string? alias,
string firstname,
string lastname,
string? profilePictureUrl)
{
var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key));
@@ -25,16 +26,19 @@ public static class JwtTokenHelper
{
new Claim(JwtRegisteredClaimNames.Sub, userId),
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
new Claim(ClaimTypes.NameIdentifier, userId),
new Claim(ClaimTypes.Email, email),
new Claim(ClaimTypes.Name, email),
new Claim(ClaimTypes.GivenName, firstname),
new Claim(ClaimTypes.Surname, lastname),
new Claim(ClaimTypes.NameIdentifier, userId), new Claim(ClaimTypes.Email, email),
new Claim(ClaimTypes.Name, email), new Claim(ClaimTypes.GivenName, firstname),
new Claim(ClaimTypes.Surname, lastname)
});
if (alias is not null)
{
claims.Add(new(KnownClaims.Alias, alias));
}
if (profilePictureUrl is not null)
{
claims.Add(new Claim("portrait-url", profilePictureUrl));
claims.Add(new(KnownClaims.PortraitUrl, profilePictureUrl));
}
var token = new JwtSecurityToken(

View File

@@ -0,0 +1,7 @@
namespace Hutopy.Infrastructure.Utils;
public static class KnownClaims
{
public const string Alias = nameof(Alias);
public const string PortraitUrl = nameof(PortraitUrl);
}