merged
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Hutopy.Application.Common.Models;
|
||||
using System.Linq;
|
||||
using Hutopy.Application.Common.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Hutopy.Infrastructure.Identity;
|
||||
|
||||
@@ -41,10 +41,42 @@ public class IdentityService(
|
||||
var userModel = new UserModel()
|
||||
{
|
||||
Id = response.Id,
|
||||
UserName = response.UserName,
|
||||
UserName = response.UserName ?? string.Empty,
|
||||
FirstName = response.FirstName,
|
||||
LastName = response.LastName,
|
||||
Email = response.Email,
|
||||
Email = response.Email ?? string.Empty,
|
||||
Occupation = response.Occupation,
|
||||
PhoneNumber = response.PhoneNumber ?? string.Empty,
|
||||
BirthDate = response.BirthDate,
|
||||
Country = response.Country,
|
||||
City = response.City,
|
||||
Address = response.Address,
|
||||
About = response.About,
|
||||
Description = response.Description,
|
||||
SocialNetworks = new SocialNetworksModel
|
||||
{
|
||||
FacebookUrl = response.SocialNetworks.FacebookUrl,
|
||||
InstagramUrl = response.SocialNetworks.InstagramUrl,
|
||||
XUrl = response.SocialNetworks.XUrl,
|
||||
LinkedInUrl = response.SocialNetworks.LinkedInUrl,
|
||||
TikTokUrl = response.SocialNetworks.TikTokUrl,
|
||||
YoutubeUrl = response.SocialNetworks.YoutubeUrl,
|
||||
RedditUrl = response.SocialNetworks.RedditUrl,
|
||||
YourWebsiteUrl = response.SocialNetworks.YourWebsiteUrl,
|
||||
},
|
||||
ProfileColors = new ProfileColorsModel
|
||||
{
|
||||
BannerTop = response.ProfileColors.BannerTop,
|
||||
BannerBottom = response.ProfileColors.BannerBottom,
|
||||
Accent = response.ProfileColors.Accent,
|
||||
Menu = response.ProfileColors.Menu
|
||||
},
|
||||
StoredDataUrls = new StoredDataUrlsModel
|
||||
{
|
||||
ProfilePictureUrl = response.StoredDataUrls.ProfilePictureUrl,
|
||||
BannerPictureUrl = response.StoredDataUrls.BannerPictureUrl,
|
||||
WebsiteIconUrl = response.StoredDataUrls.WebsiteIconUrl,
|
||||
}
|
||||
};
|
||||
|
||||
return userModel;
|
||||
@@ -88,7 +120,7 @@ public class IdentityService(
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<Result<string>> UpdateCurrentUserAsync(UserModel userModel, string? portraitUrl)
|
||||
public async Task<Result<string>> UpdateCurrentUserAsync(UserModel userModel)
|
||||
{
|
||||
var applicationUser = await userManager.FindByIdAsync(userModel.Id);
|
||||
|
||||
@@ -104,7 +136,6 @@ public class IdentityService(
|
||||
applicationUser.Address = userModel.Address;
|
||||
applicationUser.About = userModel.About;
|
||||
applicationUser.Description = userModel.Description;
|
||||
applicationUser.PortraitUrl = portraitUrl;
|
||||
applicationUser.SocialNetworks = new SocialNetworks
|
||||
{
|
||||
FacebookUrl = userModel.SocialNetworks.FacebookUrl,
|
||||
@@ -155,7 +186,6 @@ public class IdentityService(
|
||||
Address = response.Address,
|
||||
About = response.About,
|
||||
Description = response.Description,
|
||||
PortraitUrl = response.PortraitUrl,
|
||||
SocialNetworks = new SocialNetworksModel
|
||||
{
|
||||
FacebookUrl = response.SocialNetworks.FacebookUrl,
|
||||
@@ -387,7 +417,7 @@ public class IdentityService(
|
||||
email: user.Email,
|
||||
firstname: user.FirstName,
|
||||
lastname: user.LastName,
|
||||
portraitUrl: user.PortraitUrl);
|
||||
profilePictureUrl: user.StoredDataUrls.ProfilePictureUrl);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Application.Common.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
@@ -15,7 +17,7 @@ public static class JwtTokenHelper
|
||||
string? email,
|
||||
string? firstname,
|
||||
string? lastname,
|
||||
string? portraitUrl)
|
||||
string? profilePictureUrl)
|
||||
{
|
||||
var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key));
|
||||
var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
|
||||
@@ -31,9 +33,9 @@ public static class JwtTokenHelper
|
||||
new Claim(ClaimTypes.Surname, lastname),
|
||||
});
|
||||
|
||||
if (portraitUrl is not null)
|
||||
if (profilePictureUrl is not null)
|
||||
{
|
||||
claims.Add(new Claim("portrait-url", portraitUrl));
|
||||
claims.Add(new Claim("portrait-url", profilePictureUrl));
|
||||
}
|
||||
|
||||
var token = new JwtSecurityToken(
|
||||
|
||||
Reference in New Issue
Block a user