Scan Loop Last Write Time Change (#1492)

* Refactored invite user flow to separate error handling on create user flow and email flow. This should help users that have unique situations.

* Switch to using files to check LastWriteTime. Debug code in for Robbie to test on rclone

* Updated Parser namespace. Changed the LastWriteTime to check all files and folders.
This commit is contained in:
Joseph Milazzo 2022-08-30 10:29:09 -05:00 committed by GitHub
parent 521b2adc14
commit 85790dd71c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 283 additions and 264 deletions

View file

@ -472,12 +472,27 @@ namespace API.Controllers
}
var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
if (string.IsNullOrEmpty(token)) return BadRequest("There was an issue sending email");
if (string.IsNullOrEmpty(token))
{
_logger.LogError("There was an issue generating a token for the email");
return BadRequest("There was an creating the invite user");
}
user.ConfirmationToken = token;
await _unitOfWork.CommitAsync();
}
catch (Exception ex)
{
_logger.LogError(ex, "There was an error during invite user flow, unable to create user. Deleting user for retry");
_unitOfWork.UserRepository.Delete(user);
await _unitOfWork.CommitAsync();
}
var emailLink = GenerateEmailLink(token, "confirm-email", dto.Email);
try
{
var emailLink = GenerateEmailLink(user.ConfirmationToken, "confirm-email", dto.Email);
_logger.LogCritical("[Invite User]: Email Link for {UserName}: {Link}", user.UserName, emailLink);
_logger.LogCritical("[Invite User]: Token {UserName}: {Token}", user.UserName, token);
_logger.LogCritical("[Invite User]: Token {UserName}: {Token}", user.UserName, user.ConfirmationToken);
var host = _environment.IsDevelopment() ? "localhost:4200" : Request.Host.ToString();
var accessible = await _emailService.CheckIfAccessible(host);
if (accessible)
@ -490,23 +505,22 @@ namespace API.Controllers
InvitingUser = adminUser.UserName,
ServerConfirmationLink = emailLink
});
} catch(Exception) {/* Swallow exception */}
}
catch (Exception)
{
/* Swallow exception */
}
}
user.ConfirmationToken = token;
await _unitOfWork.CommitAsync();
return Ok(new InviteUserResponse
{
EmailLink = emailLink,
EmailSent = accessible
});
}
catch (Exception)
catch (Exception ex)
{
_unitOfWork.UserRepository.Delete(user);
await _unitOfWork.CommitAsync();
_logger.LogError(ex, "There was an error during invite user flow, unable to send an email");
}
return BadRequest("There was an error setting up your account. Please check the logs");