Merge branch 'feature/backups' into bugfix/webtoon-reader
This commit is contained in:
commit
ad7d7f82e6
4 changed files with 60 additions and 53 deletions
|
|
@ -26,6 +26,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.RateLimiting;
|
using Microsoft.AspNetCore.RateLimiting;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SharpCompress;
|
||||||
|
|
||||||
namespace API.Controllers;
|
namespace API.Controllers;
|
||||||
|
|
||||||
|
|
@ -137,8 +138,7 @@ public class AccountController : BaseApiController
|
||||||
if (!result.Succeeded) return BadRequest(result.Errors);
|
if (!result.Succeeded) return BadRequest(result.Errors);
|
||||||
|
|
||||||
// Assign default streams
|
// Assign default streams
|
||||||
user.DashboardStreams = Seed.DefaultStreams.ToList();
|
AddDefaultStreamsToUser(user);
|
||||||
user.SideNavStreams = Seed.DefaultSideNavStreams.ToList();
|
|
||||||
|
|
||||||
var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||||
if (string.IsNullOrEmpty(token)) return BadRequest(await _localizationService.Get("en", "confirm-token-gen"));
|
if (string.IsNullOrEmpty(token)) return BadRequest(await _localizationService.Get("en", "confirm-token-gen"));
|
||||||
|
|
@ -595,7 +595,7 @@ public class AccountController : BaseApiController
|
||||||
if (string.IsNullOrEmpty(dto.Email))
|
if (string.IsNullOrEmpty(dto.Email))
|
||||||
return BadRequest(await _localizationService.Translate(userId, "invalid-payload"));
|
return BadRequest(await _localizationService.Translate(userId, "invalid-payload"));
|
||||||
|
|
||||||
_logger.LogInformation("{User} is inviting {Email} to the server", adminUser.UserName, dto.Email);
|
_logger.LogInformation("{User} is inviting {Email} to the server", User.GetUsername(), dto.Email);
|
||||||
|
|
||||||
// Check if there is an existing invite
|
// Check if there is an existing invite
|
||||||
var emailValidationErrors = await _accountService.ValidateEmail(dto.Email);
|
var emailValidationErrors = await _accountService.ValidateEmail(dto.Email);
|
||||||
|
|
@ -608,7 +608,8 @@ public class AccountController : BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new user
|
// Create a new user
|
||||||
var user = new AppUserBuilder(dto.Email, dto.Email, await _unitOfWork.SiteThemeRepository.GetDefaultTheme()).Build();
|
var user = new AppUserBuilder(dto.Email, dto.Email,
|
||||||
|
await _unitOfWork.SiteThemeRepository.GetDefaultTheme()).Build();
|
||||||
_unitOfWork.UserRepository.Add(user);
|
_unitOfWork.UserRepository.Add(user);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -616,9 +617,7 @@ public class AccountController : BaseApiController
|
||||||
if (!result.Succeeded) return BadRequest(result.Errors);
|
if (!result.Succeeded) return BadRequest(result.Errors);
|
||||||
|
|
||||||
// Assign default streams
|
// Assign default streams
|
||||||
user.DashboardStreams = Seed.DefaultStreams.ToList();
|
AddDefaultStreamsToUser(user);
|
||||||
user.SideNavStreams = Seed.DefaultSideNavStreams.ToList();
|
|
||||||
|
|
||||||
|
|
||||||
// Assign Roles
|
// Assign Roles
|
||||||
var roles = dto.Roles;
|
var roles = dto.Roles;
|
||||||
|
|
@ -657,7 +656,6 @@ public class AccountController : BaseApiController
|
||||||
user.CreateSideNavFromLibrary(lib);
|
user.CreateSideNavFromLibrary(lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
_unitOfWork.UserRepository.Update(user);
|
|
||||||
user.AgeRestriction = hasAdminRole ? AgeRating.NotApplicable : dto.AgeRestriction.AgeRating;
|
user.AgeRestriction = hasAdminRole ? AgeRating.NotApplicable : dto.AgeRestriction.AgeRating;
|
||||||
user.AgeRestrictionIncludeUnknowns = hasAdminRole || dto.AgeRestriction.IncludeUnknowns;
|
user.AgeRestrictionIncludeUnknowns = hasAdminRole || dto.AgeRestriction.IncludeUnknowns;
|
||||||
|
|
||||||
|
|
@ -669,6 +667,7 @@ public class AccountController : BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
user.ConfirmationToken = token;
|
user.ConfirmationToken = token;
|
||||||
|
_unitOfWork.UserRepository.Update(user);
|
||||||
await _unitOfWork.CommitAsync();
|
await _unitOfWork.CommitAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -702,7 +701,7 @@ public class AccountController : BaseApiController
|
||||||
BackgroundJob.Enqueue(() => _emailService.SendConfirmationEmail(new ConfirmationEmailDto()
|
BackgroundJob.Enqueue(() => _emailService.SendConfirmationEmail(new ConfirmationEmailDto()
|
||||||
{
|
{
|
||||||
EmailAddress = dto.Email,
|
EmailAddress = dto.Email,
|
||||||
InvitingUser = adminUser.UserName!,
|
InvitingUser = User.GetUsername(),
|
||||||
ServerConfirmationLink = emailLink
|
ServerConfirmationLink = emailLink
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -721,6 +720,19 @@ public class AccountController : BaseApiController
|
||||||
return BadRequest(await _localizationService.Translate(User.GetUserId(), "generic-invite-user"));
|
return BadRequest(await _localizationService.Translate(User.GetUserId(), "generic-invite-user"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddDefaultStreamsToUser(AppUser user)
|
||||||
|
{
|
||||||
|
foreach (var newStream in Seed.DefaultStreams.Select(stream => _mapper.Map<AppUserDashboardStream, AppUserDashboardStream>(stream)))
|
||||||
|
{
|
||||||
|
user.DashboardStreams.Add(newStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var stream in Seed.DefaultSideNavStreams.Select(stream => _mapper.Map<AppUserSideNavStream, AppUserSideNavStream>(stream)))
|
||||||
|
{
|
||||||
|
user.SideNavStreams.Add(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Last step in authentication flow, confirms the email token for email
|
/// Last step in authentication flow, confirms the email token for email
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -76,48 +76,42 @@ public static class Seed
|
||||||
},
|
},
|
||||||
}.ToArray());
|
}.ToArray());
|
||||||
|
|
||||||
public static readonly ImmutableArray<AppUserSideNavStream> DefaultSideNavStreams = ImmutableArray.Create(new[]
|
public static readonly ImmutableArray<AppUserSideNavStream> DefaultSideNavStreams = ImmutableArray.Create(
|
||||||
|
new AppUserSideNavStream()
|
||||||
{
|
{
|
||||||
new AppUserSideNavStream()
|
Name = "want-to-read",
|
||||||
{
|
StreamType = SideNavStreamType.WantToRead,
|
||||||
Name = "want-to-read",
|
Order = 1,
|
||||||
StreamType = SideNavStreamType.WantToRead,
|
IsProvided = true,
|
||||||
Order = 1,
|
Visible = true
|
||||||
IsProvided = true,
|
}, new AppUserSideNavStream()
|
||||||
Visible = true
|
{
|
||||||
},
|
Name = "collections",
|
||||||
new AppUserSideNavStream()
|
StreamType = SideNavStreamType.Collections,
|
||||||
{
|
Order = 2,
|
||||||
Name = "collections",
|
IsProvided = true,
|
||||||
StreamType = SideNavStreamType.Collections,
|
Visible = true
|
||||||
Order = 2,
|
}, new AppUserSideNavStream()
|
||||||
IsProvided = true,
|
{
|
||||||
Visible = true
|
Name = "reading-lists",
|
||||||
},
|
StreamType = SideNavStreamType.ReadingLists,
|
||||||
new AppUserSideNavStream()
|
Order = 3,
|
||||||
{
|
IsProvided = true,
|
||||||
Name = "reading-lists",
|
Visible = true
|
||||||
StreamType = SideNavStreamType.ReadingLists,
|
}, new AppUserSideNavStream()
|
||||||
Order = 3,
|
{
|
||||||
IsProvided = true,
|
Name = "bookmarks",
|
||||||
Visible = true
|
StreamType = SideNavStreamType.Bookmarks,
|
||||||
},
|
Order = 4,
|
||||||
new AppUserSideNavStream()
|
IsProvided = true,
|
||||||
{
|
Visible = true
|
||||||
Name = "bookmarks",
|
}, new AppUserSideNavStream()
|
||||||
StreamType = SideNavStreamType.Bookmarks,
|
{
|
||||||
Order = 4,
|
Name = "all-series",
|
||||||
IsProvided = true,
|
StreamType = SideNavStreamType.AllSeries,
|
||||||
Visible = true
|
Order = 5,
|
||||||
},
|
IsProvided = true,
|
||||||
new AppUserSideNavStream()
|
Visible = true
|
||||||
{
|
|
||||||
Name = "all-series",
|
|
||||||
StreamType = SideNavStreamType.AllSeries,
|
|
||||||
Order = 5,
|
|
||||||
IsProvided = true,
|
|
||||||
Visible = true
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,9 +240,10 @@ public class AutoMapperProfiles : Profile
|
||||||
|
|
||||||
CreateMap<AppUserSmartFilter, SmartFilterDto>();
|
CreateMap<AppUserSmartFilter, SmartFilterDto>();
|
||||||
CreateMap<AppUserDashboardStream, DashboardStreamDto>();
|
CreateMap<AppUserDashboardStream, DashboardStreamDto>();
|
||||||
// CreateMap<AppUserDashboardStream, DashboardStreamDto>()
|
|
||||||
// .ForMember(dest => dest.SmartFilterEncoded,
|
// This is for cloning to ensure the records don't get overwritten when setting from SeedData
|
||||||
// opt => opt.MapFrom(src => src.SmartFilter));
|
CreateMap<AppUserDashboardStream, AppUserDashboardStream>();
|
||||||
|
CreateMap<AppUserSideNavStream, AppUserSideNavStream>();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue