Adds user Alias. Make StoredDataUrls optionals.
This commit is contained in:
@@ -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(
|
||||
|
||||
7
src/Infrastructure/Utils/KnownClaims.cs
Normal file
7
src/Infrastructure/Utils/KnownClaims.cs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user