Skip to content

Commit

Permalink
fix #12
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Nov 11, 2023
1 parent 850ddeb commit efd2af2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public async Task<IActionResult> RegisterAsync([FromBody] PassportRequest reques

PassportResult result = await passportService.RegisterAsync(passport).ConfigureAwait(false);
return result.Success
? Response<string>.Success("注册成功", result.Token)
? Response<string>.Success("注册成功", result.Token, result.LocalizationKey!)
: Model.Response.Response.Fail(ReturnCode.RegisterFail, result.Message);
}

Expand Down Expand Up @@ -156,7 +156,7 @@ public async Task<IActionResult> CancelAsync([FromBody] PassportRequest request)
PassportResult result = await passportService.CancelAsync(passport).ConfigureAwait(false);

return result.Success
? Model.Response.Response.Success(result.Message)
? Model.Response.Response.Success(result.Message, result.LocalizationKey!)
: Model.Response.Response.Fail(ReturnCode.CancelFail, result.Message);
}

Expand Down Expand Up @@ -191,7 +191,7 @@ public async Task<IActionResult> ResetPasswordAsync([FromBody] PassportRequest r
PassportResult result = await passportService.ResetPasswordAsync(passport).ConfigureAwait(false);

return result.Success
? Response<string>.Success("密码设置成功", result.Token)
? Response<string>.Success("密码设置成功", result.Token, result.LocalizationKey!)
: Model.Response.Response.Fail(ReturnCode.RegisterFail, result.Message, result.LocalizationKey!);
}

Expand All @@ -212,7 +212,7 @@ public async Task<IActionResult> LoginAsync([FromBody] PassportRequest request)
PassportResult result = await passportService.LoginAsync(passport).ConfigureAwait(false);

return result.Success
? Response<string>.Success("登录成功", result.Token)
? Response<string>.Success("登录成功", result.Token, result.LocalizationKey!)
: Model.Response.Response.Fail(ReturnCode.LoginFail, result.Message, result.LocalizationKey!);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ public static IActionResult Success(string msg, T data)
{
return new JsonResult(new Response<T>(ReturnCode.Success, msg, data));
}

public static IActionResult Success(string msg, T data, string key)
{
return new JsonResult(new Response<T>(ReturnCode.Success, msg, data) { LocalizationKey = key });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<PassportResult> RegisterAsync(Passport passport)
IdentityResult result = await userManager.CreateAsync(newUser, passport.Password).ConfigureAwait(false);
if (result.Succeeded)
{
return new(true, "注册成功", null, CreateToken(newUser));
return new(true, "注册成功", "ServerPassportRegisterSucceed", CreateToken(newUser));
}
else
{
Expand Down Expand Up @@ -87,7 +87,7 @@ public async Task<PassportResult> ResetPasswordAsync(Passport passport)
await userManager.RemovePasswordAsync(user).ConfigureAwait(false);
await userManager.AddPasswordAsync(user, passport.Password).ConfigureAwait(false);

return new(true, "新密码设置成功", null, CreateToken(user));
return new(true, "新密码设置成功", "ServerPassportResetPasswordSucceed", CreateToken(user));
}
else
{
Expand All @@ -106,7 +106,7 @@ public async Task<PassportResult> LoginAsync(Passport passport)
{
if (await userManager.CheckPasswordAsync(user, passport.Password).ConfigureAwait(false))
{
return new(true, "登录成功", null, CreateToken(user));
return new(true, "登录成功", "ServerPassportLoginSucceed", CreateToken(user));
}
}

Expand All @@ -125,7 +125,7 @@ public async Task<PassportResult> CancelAsync(Passport passport)
if (await userManager.CheckPasswordAsync(user, passport.Password).ConfigureAwait(false))
{
await userManager.DeleteAsync(user).ConfigureAwait(false);
return new(true, "用户注销成功", null);
return new(true, "用户注销成功", "ServerPassportUnregisterSucceed");
}
}

Expand Down

0 comments on commit efd2af2

Please sign in to comment.