Adds authentication unit tests

This commit is contained in:
BinaryAlley committed 2024-11-12 15:45:26 +02:00
1 parent a6dcf65d1c
commit 4f91f29b62
101 files changed
+5549 -135

No files matched your search

@@ -48,6 +48,14 @@ public class RegisterUserCommandHandler : IRequestHandler<RegisterUserCommand, E
_qRCodeGenerator = qRCodeGenerator;
}
/// <summary>
/// Handles the command to register an account.
/// </summary>
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="RegistrationResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<RegistrationResponse>> Handle(RegisterUserCommand request, CancellationToken cancellationToken)
{
// check if any users already exists (admin account is only set once!)
@@ -72,7 +72,7 @@ public class LoginUserQueryHandler : IRequestHandler<LoginUserQuery, ErrorOr<Log
if (resultSelectUser.Value.TempPassword is not null)
{
// the temporary password should only be valid for 15 minutes, if its obsolete, remove it and return error
if (resultSelectUser.Value.TempPasswordCreated!.Value.AddMinutes(15) > DateTime.UtcNow)
if (resultSelectUser.Value.TempPasswordCreated!.Value.AddMinutes(15) < DateTime.UtcNow)
{
resultSelectUser.Value.TempPassword = null;
resultSelectUser.Value.TempPasswordCreated = null;