Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 35 additions & 33 deletions DigitalLearningSolutions.Data/Models/User/User.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
namespace DigitalLearningSolutions.Data.Models.User
{
public abstract class User : BaseSearchableItem
{
public int Id { get; set; }

public int CentreId { get; set; }

public string CentreName { get; set; }

public bool CentreActive { get; set; }

public string? FirstName { get; set; }

public string LastName { get; set; }

public string? EmailAddress { get; set; }

public string? Password { get; set; }

public int? ResetPasswordId { get; set; }

public byte[]? ProfileImage { get; set; }

public override string SearchableName
{
get => SearchableNameOverrideForFuzzySharp ?? $"{FirstName} {LastName}";
set => SearchableNameOverrideForFuzzySharp = value;
}

public abstract UserReference ToUserReference();
}
}
namespace DigitalLearningSolutions.Data.Models.User
{
public abstract class User : BaseSearchableItem
{
public int Id { get; set; }

public int CentreId { get; set; }

public string CentreName { get; set; }

public bool CentreActive { get; set; }

public string? FirstName { get; set; }

public string LastName { get; set; }

public string? EmailAddress { get; set; }

public string? Password { get; set; }

public int? ResetPasswordId { get; set; }

public byte[]? ProfileImage { get; set; }

public override string SearchableName
{
get => SearchableNameOverrideForFuzzySharp ?? $"{FirstName} {LastName}";
set => SearchableNameOverrideForFuzzySharp = value;
}

public string FullName => FirstName == null ? LastName : $"{FirstName} {LastName}";

public abstract UserReference ToUserReference();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public interface IDelegateApprovalsService

public class DelegateApprovalsService : IDelegateApprovalsService
{
private readonly ICentreCustomPromptsService centreCustomPromptsService;
private readonly ICentresDataService centresDataService;
private readonly IConfiguration config;
private readonly ICentreCustomPromptsService centreCustomPromptsService;
private readonly IEmailService emailService;
private readonly ILogger<DelegateApprovalsService> logger;
private readonly IUserDataService userDataService;
Expand Down Expand Up @@ -153,7 +153,7 @@ private void SendRejectionEmail(DelegateUser delegateUser)
else
{
var delegateRejectionEmail = GenerateDelegateRejectionEmail(
delegateUser.FirstName,
delegateUser.FullName,
delegateUser.CentreName,
delegateUser.EmailAddress,
FindCentreUrl
Expand Down
18 changes: 7 additions & 11 deletions DigitalLearningSolutions.Data/Services/PasswordResetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void GenerateAndSendPasswordResetLink(string emailAddress, string baseUrl
var resetPasswordEmail = GeneratePasswordResetEmail(
emailAddress,
resetPasswordHash,
user.FirstName,
user.FullName,
baseUrl
);
emailService.SendEmail(resetPasswordEmail);
Expand Down Expand Up @@ -131,7 +131,7 @@ private string GenerateResetPasswordHash(User user)
private static Email GeneratePasswordResetEmail(
string emailAddress,
string resetHash,
string? firstName,
string fullName,
string baseUrl
)
{
Expand All @@ -146,17 +146,15 @@ string baseUrl

string emailSubject = "Digital Learning Solutions Tracking System Password Reset";

var nameToUse = firstName ?? "User";

var body = new BodyBuilder
{
TextBody = $@"Dear {nameToUse},
TextBody = $@"Dear {fullName},
A request has been made to reset the password for your Digital Learning Solutions account.
To reset your password please follow this link: {resetPasswordUrl.Uri}
Note that this link can only be used once and it will expire in two hours.
Please don’t reply to this email as it has been automatically generated.",
HtmlBody = $@"<body style= 'font-family: Calibri; font-size: small;'>
<p>Dear {nameToUse},</p>
<p>Dear {fullName},</p>
<p>A request has been made to reset the password for your Digital Learning Solutions account.</p>
<p>To reset your password please follow this link: <a href=""{resetPasswordUrl.Uri}"">{resetPasswordUrl.Uri}</a></p>
<p>Note that this link can only be used once and it will expire in two hours.</p>
Expand Down Expand Up @@ -185,21 +183,19 @@ DelegateUser delegateUser

const string emailSubject = "Welcome to Digital Learning Solutions - Verify your Registration";

var nameToUse = delegateUser.FirstName != null ? $"{delegateUser.FirstName} {delegateUser.LastName}" : delegateUser.LastName;

BodyBuilder body = new BodyBuilder
{
TextBody = $@"Dear {nameToUse},
TextBody = $@"Dear {delegateUser.FullName},
An administrator has registered your details to give you access to the Digital Learning Solutions (DLS) platform under the centre {delegateUser.CentreName}.
You have been assigned the unique DLS delegate number {delegateUser.CandidateNumber}.
To complete your registration and access your Digital Learning Solutions content, please click: {setPasswordUrl.Uri}
Note that this link can only be used once and it will expire in three days.
Please don't reply to this email as it has been automatically generated.",
HtmlBody = $@"<body style= 'font-family: Calibri; font-size: small;'>
<p>Dear {nameToUse},</p>
<p>Dear {delegateUser.FullName},</p>
<p>An administrator has registered your details to give you access to the Digital Learning Solutions (DLS) platform under the centre {delegateUser.CentreName}.</p>
<p>You have been assigned the unique DLS delegate number {delegateUser.CandidateNumber}.</p>
<p>To complete your registration and access your Digital Learning Solutions content, please click <a href=""{setPasswordUrl.Uri}"">this link</a>.</p>
<p><a href=""{setPasswordUrl.Uri}"">Click here to complete your registration and access your Digital Learning Solutions content</a></p>
<p>Note that this link can only be used once and it will expire in three days.</p>
<p>Please don't reply to this email as it has been automatically generated.</p>
</body>"
Expand Down