Hotfix Prep (#2484)
This commit is contained in:
parent
8c16b87ff0
commit
bd4cbeb393
22 changed files with 114 additions and 87 deletions
|
@ -26,6 +26,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SharpCompress;
|
||||
|
||||
namespace API.Controllers;
|
||||
|
||||
|
@ -137,8 +138,7 @@ public class AccountController : BaseApiController
|
|||
if (!result.Succeeded) return BadRequest(result.Errors);
|
||||
|
||||
// Assign default streams
|
||||
user.DashboardStreams = Seed.DefaultStreams.ToList();
|
||||
user.SideNavStreams = Seed.DefaultSideNavStreams.ToList();
|
||||
AddDefaultStreamsToUser(user);
|
||||
|
||||
var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||
if (string.IsNullOrEmpty(token)) return BadRequest(await _localizationService.Get("en", "confirm-token-gen"));
|
||||
|
@ -608,7 +608,8 @@ public class AccountController : BaseApiController
|
|||
}
|
||||
|
||||
// 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);
|
||||
try
|
||||
{
|
||||
|
@ -616,9 +617,7 @@ public class AccountController : BaseApiController
|
|||
if (!result.Succeeded) return BadRequest(result.Errors);
|
||||
|
||||
// Assign default streams
|
||||
user.DashboardStreams = Seed.DefaultStreams.ToList();
|
||||
user.SideNavStreams = Seed.DefaultSideNavStreams.ToList();
|
||||
|
||||
AddDefaultStreamsToUser(user);
|
||||
|
||||
// Assign Roles
|
||||
var roles = dto.Roles;
|
||||
|
@ -657,7 +656,6 @@ public class AccountController : BaseApiController
|
|||
user.CreateSideNavFromLibrary(lib);
|
||||
}
|
||||
|
||||
_unitOfWork.UserRepository.Update(user);
|
||||
user.AgeRestriction = hasAdminRole ? AgeRating.NotApplicable : dto.AgeRestriction.AgeRating;
|
||||
user.AgeRestrictionIncludeUnknowns = hasAdminRole || dto.AgeRestriction.IncludeUnknowns;
|
||||
|
||||
|
@ -669,6 +667,7 @@ public class AccountController : BaseApiController
|
|||
}
|
||||
|
||||
user.ConfirmationToken = token;
|
||||
_unitOfWork.UserRepository.Update(user);
|
||||
await _unitOfWork.CommitAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -702,7 +701,7 @@ public class AccountController : BaseApiController
|
|||
BackgroundJob.Enqueue(() => _emailService.SendConfirmationEmail(new ConfirmationEmailDto()
|
||||
{
|
||||
EmailAddress = dto.Email,
|
||||
InvitingUser = adminUser.UserName!,
|
||||
InvitingUser = adminUser.UserName,
|
||||
ServerConfirmationLink = emailLink
|
||||
}));
|
||||
}
|
||||
|
@ -721,6 +720,19 @@ public class AccountController : BaseApiController
|
|||
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>
|
||||
/// Last step in authentication flow, confirms the email token for email
|
||||
/// </summary>
|
||||
|
|
|
@ -115,10 +115,6 @@ public class ReaderController : BaseApiController
|
|||
|
||||
try
|
||||
{
|
||||
if (new Random().Next(1, 10) > 5)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
var chapter = await _cacheService.Ensure(chapterId, extractPdf);
|
||||
if (chapter == null) return NoContent();
|
||||
_logger.LogInformation("Fetching Page {PageNum} on Chapter {ChapterId}", page, chapterId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue