diff --git a/Chat/Chat.cs b/Chat/Chat.cs index 10551b8..8c78a0b 100644 --- a/Chat/Chat.cs +++ b/Chat/Chat.cs @@ -223,9 +223,9 @@ namespace WebAppServer1.Chat pgSql.Add(newUser); await pgSql.SaveChangesAsync(); logger.LogInformation($"新用户:{newUser.Username}正在进行登录注册操作!密码:{newUser.Nickname}"); - await Clients.Client(Context.ConnectionId).SendAsync("RegisterResult", true,"恭喜注册成功!"); + await LoginAuthentication(newUser.Username,newUser.PasswordHash); - + await Clients.Client(Context.ConnectionId).SendAsync("RegisterResult", true, "恭喜注册成功!"); } //统计在线人数 diff --git a/Models/ResultResponse.cs b/Models/ResultResponse.cs index 17257e6..7a37eba 100644 --- a/Models/ResultResponse.cs +++ b/Models/ResultResponse.cs @@ -8,8 +8,23 @@ namespace WebAppServer1.Models [Key("success")] public bool success { get; set; } [Key("username")] - public string username { get; set; } + public string username { get; set; } = string.Empty; [Key("userid")] public int userid { get; set; } }; + + [MessagePackObject] + public class LoginResultResponse + { + [Key("Nickname")] + public string Nickname { get; set; } = string.Empty; + [Key("Id")] + public int Id { get; set; } + [Key("AvatarUrl")] + public string AvatarUrl { get; set; } = string.Empty; + [Key("Signature")] + public string Signature { get; set; } = string.Empty; + [Key("IsOnline")] + public bool IsOnline { get; set; } + } }