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

@@ -2,8 +2,6 @@ using Google.Apis.Oauth2.v2.Data;
using System.Security.Claims;
using Hutopy.Application.Common.Interfaces;
using Hutopy.Application.Common.Models;
using Hutopy.Application.Users.Models;
using Hutopy.Infrastructure.Identity.OwnedEntities;
using Hutopy.Infrastructure.Utils;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@@ -31,53 +29,52 @@ public class IdentityService(
public async Task<UserModel?> GetUserByUserNameAsync(string userName)
{
var response = await userManager.FindByNameAsync(userName);
var user = await userManager.FindByNameAsync(userName);
if (response == null) return null;
if (user == null) return null;
var userModel = new UserModel()
return new()
{
Id = response.Id,
CreatorAlias = response.CreatorAlias,
UserName = response.UserName ?? string.Empty,
FirstName = response.FirstName,
LastName = response.LastName,
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
Id = user.Id,
CreatorAlias = user.CreatorAlias,
UserName = user.UserName ?? string.Empty,
Alias = user.Alias,
FirstName = user.FirstName,
LastName = user.LastName,
Email = user.Email ?? string.Empty,
Occupation = user.Occupation,
PhoneNumber = user.PhoneNumber ?? string.Empty,
BirthDate = user.BirthDate,
Country = user.Country,
City = user.City,
Address = user.Address,
About = user.About,
Description = user.Description,
SocialNetworks = new()
{
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,
FacebookUrl = user.SocialNetworks.FacebookUrl,
InstagramUrl = user.SocialNetworks.InstagramUrl,
XUrl = user.SocialNetworks.XUrl,
LinkedInUrl = user.SocialNetworks.LinkedInUrl,
TikTokUrl = user.SocialNetworks.TikTokUrl,
YoutubeUrl = user.SocialNetworks.YoutubeUrl,
RedditUrl = user.SocialNetworks.RedditUrl,
YourWebsiteUrl = user.SocialNetworks.YourWebsiteUrl,
},
ProfileColors = new ProfileColorsModel
ProfileColors = new()
{
BannerTop = response.ProfileColors.BannerTop,
BannerBottom = response.ProfileColors.BannerBottom,
Accent = response.ProfileColors.Accent,
Menu = response.ProfileColors.Menu
BannerTop = user.ProfileColors.BannerTop,
BannerBottom = user.ProfileColors.BannerBottom,
Accent = user.ProfileColors.Accent,
Menu = user.ProfileColors.Menu
},
StoredDataUrls = new StoredDataUrlsModel
StoredDataUrls = new()
{
ProfilePictureUrl = response.StoredDataUrls.ProfilePictureUrl,
BannerPictureUrl = response.StoredDataUrls.BannerPictureUrl,
WebsiteIconUrl = response.StoredDataUrls.WebsiteIconUrl,
ProfilePictureUrl = user.StoredDataUrls.ProfilePictureUrl,
BannerPictureUrl = user.StoredDataUrls.BannerPictureUrl,
WebsiteIconUrl = user.StoredDataUrls.WebsiteIconUrl,
}
};
return userModel;
}
public async Task<Result<string>> CreateUserAsync(Userinfo userInfo)
@@ -134,7 +131,7 @@ public class IdentityService(
applicationUser.Address = userModel.Address;
applicationUser.About = userModel.About;
applicationUser.Description = userModel.Description;
applicationUser.SocialNetworks = new SocialNetworks
applicationUser.SocialNetworks = new()
{
FacebookUrl = userModel.SocialNetworks.FacebookUrl,
InstagramUrl = userModel.SocialNetworks.InstagramUrl,
@@ -145,7 +142,7 @@ public class IdentityService(
RedditUrl = userModel.SocialNetworks.RedditUrl,
YourWebsiteUrl = userModel.SocialNetworks.YourWebsiteUrl
};
applicationUser.ProfileColors = new ProfileColors
applicationUser.ProfileColors = new()
{
BannerTop = userModel.ProfileColors.BannerTop,
BannerBottom = userModel.ProfileColors.BannerBottom,
@@ -192,6 +189,7 @@ public class IdentityService(
Id = response.Id,
CreatorAlias = response.CreatorAlias,
UserName = response.UserName ?? string.Empty,
Alias = response.Alias,
FirstName = response.FirstName,
LastName = response.LastName,
Email = response.Email ?? string.Empty,
@@ -203,7 +201,7 @@ public class IdentityService(
Address = response.Address,
About = response.About,
Description = response.Description,
SocialNetworks = new SocialNetworksModel
SocialNetworks = new()
{
FacebookUrl = response.SocialNetworks.FacebookUrl,
InstagramUrl = response.SocialNetworks.InstagramUrl,
@@ -214,14 +212,14 @@ public class IdentityService(
RedditUrl = response.SocialNetworks.RedditUrl,
YourWebsiteUrl = response.SocialNetworks.YourWebsiteUrl,
},
ProfileColors = new ProfileColorsModel
ProfileColors = new()
{
BannerTop = response.ProfileColors.BannerTop,
BannerBottom = response.ProfileColors.BannerBottom,
Accent = response.ProfileColors.Accent,
Menu = response.ProfileColors.Menu
},
StoredDataUrls = new StoredDataUrlsModel
StoredDataUrls = new()
{
ProfilePictureUrl = response.StoredDataUrls.ProfilePictureUrl,
BannerPictureUrl = response.StoredDataUrls.BannerPictureUrl,
@@ -253,7 +251,7 @@ public class IdentityService(
Address = response.Address,
About = response.About,
Description = response.Description,
SocialNetworks = new SocialNetworksModel
SocialNetworks = new()
{
FacebookUrl = response.SocialNetworks.FacebookUrl,
InstagramUrl = response.SocialNetworks.InstagramUrl,
@@ -264,14 +262,14 @@ public class IdentityService(
RedditUrl = response.SocialNetworks.RedditUrl,
YourWebsiteUrl = response.SocialNetworks.YourWebsiteUrl,
},
ProfileColors = new ProfileColorsModel
ProfileColors = new()
{
BannerTop = response.ProfileColors.BannerTop,
BannerBottom = response.ProfileColors.BannerBottom,
Accent = response.ProfileColors.Accent,
Menu = response.ProfileColors.Menu
},
StoredDataUrls = new StoredDataUrlsModel
StoredDataUrls = new()
{
ProfilePictureUrl = response.StoredDataUrls.ProfilePictureUrl,
BannerPictureUrl = response.StoredDataUrls.BannerPictureUrl,
@@ -431,6 +429,7 @@ public class IdentityService(
key: jwtOptions.Value.Key,
userId: user.Id,
email: user.Email,
alias: user.Alias,
firstname: user.FirstName,
lastname: user.LastName,
profilePictureUrl: user.StoredDataUrls.ProfilePictureUrl);