feat(EnvelopeClaimTypes): „envelope ID“ als Auth-Claim hinzugefügt.
This commit is contained in:
parent
bfd4e6a8ed
commit
da28a7332b
@ -52,8 +52,7 @@ namespace EnvelopeGenerator.Application
|
||||
|
||||
services.Configure<DispatcherConfig>(dispatcherConfigSection);
|
||||
services.Configure<MailConfig>(mailConfigSection);
|
||||
//services.Configure<MailConfig>(mailConfig.GetSection(typeof(MailConfig).ToString()));
|
||||
//IConfigurationSection section = builder.Configuration.GetSection(typeof(T).Name);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
@ -3,13 +3,16 @@
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly
|
||||
{
|
||||
public record EnvelopeReceiverReadOnlyCreateDto(
|
||||
long EnvelopeId,
|
||||
string ReceiverMail,
|
||||
DateTime DateValid)
|
||||
{
|
||||
[JsonIgnore]
|
||||
public long? EnvelopeId { get; set; } = null;
|
||||
|
||||
[JsonIgnore]
|
||||
public string? AddedWho { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime AddedWhen { get; } = DateTime.Now;
|
||||
};
|
||||
}
|
||||
@ -18,6 +18,12 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
|
||||
public static string? GetAuthEnvelopeTitle(this ControllerBase controller) => controller.User.FindFirstValue(EnvelopeClaimTypes.Title);
|
||||
|
||||
public static int? GetAuthEnvelopeId(this ControllerBase controller)
|
||||
{
|
||||
var env_id_str = controller.User.FindFirstValue(EnvelopeClaimTypes.Id);
|
||||
return int.TryParse(env_id_str, out int env_id) ? env_id : null;
|
||||
}
|
||||
|
||||
//TODO: integrate localizer for ready-to-use views
|
||||
public static ViewResult ViewError(this Controller controller, ErrorViewModel errorViewModel) => controller.View("_Error", errorViewModel);
|
||||
|
||||
|
||||
@ -199,14 +199,15 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
{
|
||||
_logger.LogEnvelopeError(envelopeReceiverId: envelopeReceiverId, message: "No document was found.");
|
||||
return this.ViewDocumentNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
var claims = new List<Claim> {
|
||||
new(ClaimTypes.NameIdentifier, uuid),
|
||||
new(ClaimTypes.Hash, signature),
|
||||
new(ClaimTypes.Name, er.Name ?? string.Empty),
|
||||
new(ClaimTypes.Email, er.Receiver.EmailAddress),
|
||||
new(EnvelopeClaimTypes.Title, er.Envelope.Title)
|
||||
new(EnvelopeClaimTypes.Title, er.Envelope.Title),
|
||||
new(EnvelopeClaimTypes.Id, er.Envelope.Id.ToString())
|
||||
};
|
||||
|
||||
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
|
||||
@ -9,5 +9,10 @@
|
||||
/// Claim type for the title of an envelope.
|
||||
/// </summary>
|
||||
public static readonly string Title = $"Envelope{nameof(Title)}";
|
||||
|
||||
/// <summary>
|
||||
/// Claim type for the ID of an envelope.
|
||||
/// </summary>
|
||||
public static readonly string Id = $"Envelope{nameof(Id)}";
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user