fix authorize
This commit is contained in:
@@ -119,9 +119,21 @@ else
|
||||
var token = dprop.TryGetProperty("token", out var t) ? t.GetString() ?? string.Empty : string.Empty;
|
||||
var refresh = dprop.TryGetProperty("refreshToken", out var r) ? r.GetString() ?? string.Empty : string.Empty;
|
||||
|
||||
// WASM 的 localStorage 在 Server Circuit 中无意义,这里不用写 localStorage。
|
||||
// WASM 的 localStorage 在 Server Circuit 中无意义,兼容auto模式写入 localStorage。
|
||||
try
|
||||
{
|
||||
await localStorage.SetItemAsync(StorageKeys.AccessToken, token);
|
||||
await localStorage.SetItemAsync(StorageKeys.RefreshToken, refresh);
|
||||
|
||||
if (AuthStateProvider is PersistentAuthenticationStateProvider provider)
|
||||
{
|
||||
provider.UpdateAuthenticationState(token);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
// 浏览器已通过 fetch 收到 Set-Cookie;强制重载使 Circuit 使用新 Cookie。
|
||||
Logger.LogInformation("登录成功,server 跳转: {ReturnUrl}", ReturnUrl);
|
||||
Logger.LogInformation($"登录成功,server 跳转: {ReturnUrl}");
|
||||
Navigation.NavigateTo(ReturnUrl ?? "/", forceLoad: true);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user