Refaktorisierung von EnvelopeReceiverService und EnvelopeReceiverController
- Methode `ReadSecretByUuidAsync` zu `EnvelopeReceiverService` hinzugefügt, um Geheimnisse anhand der UUID abzurufen. - Fehlerbehandlung und Protokollierung in den Methoden von `EnvelopeReceiverService` verbessert, einschließlich besserer Handhabung von Sicherheitsvorfällen und Datenintegritätsproblemen. - `VerifyAccessCodeAsync` aktualisiert, um explizite Nachrichten für Sicherheitsvorfälle und Datenintegritätsprobleme zu enthalten. - `EnvelopeReceiverController` aktualisiert, um einen neuen Endpunkt `GetSecretAsync` zum Abrufen von Geheimnissen anhand der UUID einzuführen. - Fehlerbehandlung und Protokollierung in den Methoden von `EnvelopeReceiverController` verbessert. - Endpunkte angepasst, um die neue Methode `ReadSecretByUuidAsync` in der Servicelogik zu nutzen.
This commit is contained in:
parent
18e21b0a8e
commit
9adb49df78
@ -11,6 +11,8 @@ namespace EnvelopeGenerator.Application.Contracts
|
||||
|
||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUuidAsync(string uuid, bool withEnvelope = true, bool withReceiver = false);
|
||||
|
||||
Task<DataResult<IEnumerable<EnvelopeReceiverSecretDto>>> ReadSecretByUuidAsync(string uuid, bool withEnvelope = false, bool withReceiver = true);
|
||||
|
||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadBySignatureAsync(string signature, bool withEnvelope = false, bool withReceiver = true);
|
||||
|
||||
Task<DataResult<EnvelopeReceiverDto>> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true);
|
||||
@ -28,7 +30,5 @@ namespace EnvelopeGenerator.Application.Contracts
|
||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
||||
|
||||
Task<DataResult<string?>> ReadLastUsedReceiverNameByMail(string mail);
|
||||
|
||||
Task<DataResult<IEnumerable<ReceiverReadDto>>> ReadReceiverByEnvelopeAsync(string uuid);
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,6 @@ using DigitalData.Core.Application;
|
||||
using DigitalData.Core.DTO;
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
using EnvelopeGenerator.Application.Resources;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
||||
@ -34,6 +33,12 @@ namespace EnvelopeGenerator.Application.Services
|
||||
return Result.Success(_mapper.MapOrThrow<IEnumerable<EnvelopeReceiverDto>>(env_rcvs));
|
||||
}
|
||||
|
||||
public async Task<DataResult<IEnumerable<EnvelopeReceiverSecretDto>>> ReadSecretByUuidAsync(string uuid, bool withEnvelope = false, bool withReceiver = true)
|
||||
{
|
||||
var env_rcvs = await _repository.ReadByUuidAsync(uuid: uuid, withEnvelope: withEnvelope, withReceiver: withReceiver);
|
||||
return Result.Success(_mapper.MapOrThrow<IEnumerable<EnvelopeReceiverSecretDto>>(env_rcvs));
|
||||
}
|
||||
|
||||
public async Task<DataResult<EnvelopeReceiverDto>> ReadByUuidSignatureAsync(string uuid, string signature, bool withEnvelope = true, bool withReceiver = true)
|
||||
{
|
||||
var env_rcv = await _repository.ReadByUuidSignatureAsync(uuid: uuid, signature: signature, withEnvelope: withEnvelope, withReceiver: withReceiver);
|
||||
@ -129,12 +134,5 @@ namespace EnvelopeGenerator.Application.Services
|
||||
var er = await _repository.ReadLastByReceiver(mail);
|
||||
return er is null ? Result.Fail<string?>().Notice(LogLevel.None, Flag.NotFound) : Result.Success(er.Name);
|
||||
}
|
||||
|
||||
public async Task<DataResult<IEnumerable<ReceiverReadDto>>> ReadReceiverByEnvelopeAsync(string uuid)
|
||||
{
|
||||
var receivers = await _repository.ReadReceiverByEnvelopeAsync(uuid);
|
||||
var receiverDtos = _mapper.MapOrThrow<IEnumerable<ReceiverReadDto>>(receivers);
|
||||
return Result.Success(receiverDtos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,12 +74,13 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("receiver")]
|
||||
public async Task<IActionResult> GetReceiverByEnvelopeAsync([FromQuery] string uuid)
|
||||
[HttpGet("secret")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> GetSecretAsync([FromQuery] string uuid)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _erService.ReadReceiverByEnvelopeAsync(uuid: uuid).ThenAsync(
|
||||
return await _erService.ReadSecretByUuidAsync(uuid: uuid).ThenAsync(
|
||||
Success: Ok,
|
||||
Fail: IActionResult (msg, ntc) =>
|
||||
{
|
||||
|
||||
@ -22,7 +22,5 @@ namespace EnvelopeGenerator.Infrastructure.Contracts
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
||||
|
||||
Task<EnvelopeReceiver?> ReadLastByReceiver(string email);
|
||||
|
||||
Task<IEnumerable<Receiver>> ReadReceiverByEnvelopeAsync(string uuid);
|
||||
}
|
||||
}
|
||||
@ -79,11 +79,6 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
||||
public async Task<EnvelopeReceiver?> ReadLastByReceiver(string email)
|
||||
{
|
||||
return await _dbSet.Where(er => er.Receiver!.EmailAddress == email).OrderBy(er => er.EnvelopeId).LastOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Receiver>> ReadReceiverByEnvelopeAsync(string uuid)
|
||||
=> await ReadWhere(uuid: uuid, withEnvelope: false, withReceiver: true)
|
||||
.Select(er => er.Receiver!)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user