11using System . Text . Json . Serialization ;
2+ using Microsoft . AspNetCore . Mvc . ModelBinding . Binders ;
23using SimpleWebChatApplication . Services ;
34
45namespace SimpleWebChatApplication . Controllers . Models ;
@@ -18,19 +19,36 @@ public readonly struct RegisterUserPostResponse {
1819/// RegisterController 用户 Post 方法用户数据序列化模板。
1920/// </summary>
2021public readonly struct RegisterUserPostJsonSerializeTemplate {
21- public RegisterUserPostJsonSerializeTemplate ( ) => HMACKey = IGeneralTools . GenerateRandomData ( 16 ) . ToArray ( ) ;
22+ public RegisterUserPostJsonSerializeTemplate ( ) => _hmacKey = IGeneralTools . GenerateRandomData ( 16 ) . ToArray ( ) ;
2223
2324 [ JsonPropertyName ( "a" ) ]
2425 public string ? Account { get ; init ; }
2526
27+ private readonly byte [ ] ? _passwordHash ;
28+
2629 [ JsonPropertyName ( "h" ) ]
27- public byte [ ] ? PasswordHash { get ; init ; }
30+ public byte [ ] ? PasswordHash {
31+ get => ( byte [ ] ? ) _passwordHash ? . Clone ( ) ;
32+ init => _passwordHash = value ;
33+ }
34+
35+ private readonly byte [ ] ? _passwordSalt ;
2836
2937 [ JsonPropertyName ( "s" ) ]
30- public byte [ ] ? PasswordSalt { get ; init ; }
38+ public byte [ ] ? PasswordSalt {
39+ get => ( byte [ ] ? ) _passwordSalt ? . Clone ( ) ;
40+ init => _passwordSalt = value ;
41+ }
42+
43+ private readonly byte [ ] _hmacKey ;
44+
45+ private byte [ ] GetHMACKey ( ) => ( byte [ ] ) _hmacKey . Clone ( ) ;
3146
3247 [ JsonPropertyName ( "k" ) ]
33- public byte [ ] HMACKey { get ; init ; }
48+ public byte [ ] HMACKey {
49+ get => GetHMACKey ( ) ;
50+ init => _hmacKey = value ;
51+ }
3452}
3553
3654
0 commit comments