blob: 92a63874dba2ff7c1db9843939f5de33532bc373 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
using AutoMapper;
using System.ComponentModel.DataAnnotations;
using Timeline.Controllers;
using Timeline.Models.Validation;
using Timeline.Services;
namespace Timeline.Models.Http
{
/// <summary>
/// Request model for <see cref="UserController.Patch(UserPatchRequest, string)"/>.
/// </summary>
public class UserPatchRequest
{
/// <summary>
/// New username. Null if not change. Need to be administrator.
/// </summary>
[Username]
public string? Username { get; set; }
/// <summary>
/// New password. Null if not change. Need to be administrator.
/// </summary>
[MinLength(1)]
public string? Password { get; set; }
/// <summary>
/// New nickname. Null if not change. Need to be administrator to change other's.
/// </summary>
[Nickname]
public string? Nickname { get; set; }
}
/// <summary>
/// Request model for <see cref="UserController.CreateUser(CreateUserRequest)"/>.
/// </summary>
public class CreateUserRequest
{
/// <summary>
/// Username of the new user.
/// </summary>
[Required, Username]
public string Username { get; set; } = default!;
/// <summary>
/// Password of the new user.
/// </summary>
[Required, MinLength(1)]
public string Password { get; set; } = default!;
}
/// <summary>
/// Request model for <see cref="UserController.ChangePassword(ChangePasswordRequest)"/>.
/// </summary>
public class ChangePasswordRequest
{
/// <summary>
/// Old password.
/// </summary>
[Required(AllowEmptyStrings = false)]
public string OldPassword { get; set; } = default!;
/// <summary>
/// New password.
/// </summary>
[Required(AllowEmptyStrings = false)]
public string NewPassword { get; set; } = default!;
}
public class UserControllerAutoMapperProfile : Profile
{
public UserControllerAutoMapperProfile()
{
CreateMap<UserPatchRequest, ModifyUserParams>();
}
}
}
|