| | | 1 | | using System.Text.Json.Serialization; |
| | | 2 | | using ArturRios.Heimdall.Shared.Security; |
| | | 3 | | using ArturRios.Mediator.Command; |
| | | 4 | | |
| | | 5 | | namespace ArturRios.Heimdall.Command.Input; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Intent to update a person's name, email, and — for a System Admin — role (UC-08). The person |
| | | 9 | | /// is addressed by <see cref="Id" />, assigned from the route. PUT semantics: <see cref="Name" /> |
| | | 10 | | /// and <see cref="Email" /> are replaced. <see cref="RoleId" /> is optional; <c>null</c> leaves |
| | | 11 | | /// the role unchanged, which is what every non-System-Admin caller sends. A caller changing their |
| | | 12 | | /// own email also proves they are the account holder with <see cref="CurrentPassword" />, and |
| | | 13 | | /// <see cref="TwoFactorCode" /> when their second factor is active (FR-PE-14). |
| | | 14 | | /// <see cref="ActingPersonId" />/<see cref="ActingRole" /> are set by the controller from the |
| | | 15 | | /// authenticated caller and are never bound from the body. All three are <c>[JsonIgnore]</c>, so |
| | | 16 | | /// they are not deserialized from the body and do not appear in the request schema. |
| | | 17 | | /// </summary> |
| | | 18 | | public class UpdatePersonCommand : BaseCommand, IActorScoped |
| | | 19 | | { |
| | | 20 | | /// <summary>Public identifier of the person to update (assigned from the route).</summary> |
| | | 21 | | [JsonIgnore] |
| | 230 | 22 | | public Guid Id { get; set; } |
| | | 23 | | |
| | | 24 | | /// <summary>New full name. Required, max 200 characters.</summary> |
| | 455 | 25 | | public string Name { get; set; } = string.Empty; |
| | | 26 | | |
| | | 27 | | /// <summary>New email address. Required; changing it clears <c>EmailVerified</c> (UC-08 step 4).</summary> |
| | 654 | 28 | | public string Email { get; set; } = string.Empty; |
| | | 29 | | |
| | | 30 | | /// <summary>New role value (see <c>Roles</c>), or <c>null</c> to leave the role unchanged.</summary> |
| | 265 | 31 | | public int? RoleId { get; set; } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// The caller's current password. Required only when the caller changes their own email |
| | | 35 | | /// (FR-PE-14); ignored otherwise, so an administrator updating someone else sends none. |
| | | 36 | | /// </summary> |
| | 264 | 37 | | public string? CurrentPassword { get; set; } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// A current second factor — an authenticator-app or email code, or an unused recovery code — |
| | | 41 | | /// required beside <see cref="CurrentPassword" /> when the caller changes their own email and |
| | | 42 | | /// their two-factor authentication is active (FR-PE-14); ignored otherwise. |
| | | 43 | | /// </summary> |
| | 99 | 44 | | public string? TwoFactorCode { get; set; } |
| | | 45 | | |
| | | 46 | | [JsonIgnore] |
| | 436 | 47 | | public Guid ActingPersonId { get; set; } |
| | | 48 | | |
| | | 49 | | [JsonIgnore] |
| | 278 | 50 | | public int ActingRole { get; set; } |
| | | 51 | | } |