aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models/Http/UserController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-08-20 00:39:09 +0800
committercrupest <crupest@outlook.com>2020-08-20 00:39:09 +0800
commit32fdf425e6b4f4edfb727fb3c0cbebe2c87fd663 (patch)
treeba373b6b022d96cc0b3723d693296b42374ec465 /Timeline/Models/Http/UserController.cs
parent44b410f359f64e6cb69d506b5689d2b3df715c74 (diff)
downloadtimeline-32fdf425e6b4f4edfb727fb3c0cbebe2c87fd663.tar.gz
timeline-32fdf425e6b4f4edfb727fb3c0cbebe2c87fd663.tar.bz2
timeline-32fdf425e6b4f4edfb727fb3c0cbebe2c87fd663.zip
...
Diffstat (limited to 'Timeline/Models/Http/UserController.cs')
-rw-r--r--Timeline/Models/Http/UserController.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Timeline/Models/Http/UserController.cs b/Timeline/Models/Http/UserController.cs
index 5ee02a95..ea30a0ea 100644
--- a/Timeline/Models/Http/UserController.cs
+++ b/Timeline/Models/Http/UserController.cs
@@ -1,48 +1,95 @@
using AutoMapper;
using System.ComponentModel.DataAnnotations;
+using Timeline.Controllers;
using Timeline.Models.Validation;
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>
+ /// Whether to be administrator. Null if not change. Need to be administrator.
+ /// </summary>
public bool? Administrator { 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>
+ /// Whether the new user is administrator.
+ /// </summary>
[Required]
public bool? Administrator { get; set; }
+ /// <summary>
+ /// Nickname of the new user.
+ /// </summary>
[Nickname]
public string? Nickname { get; set; }
}
+ /// <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!;
}
+ /// <summary>
+ ///
+ /// </summary>
public class UserControllerAutoMapperProfile : Profile
{
+ /// <summary>
+ ///
+ /// </summary>
public UserControllerAutoMapperProfile()
{
CreateMap<UserPatchRequest, User>(MemberList.Source);