Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
处理登陆错误cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
qedsd committed Jun 6, 2021
1 parent e030600 commit 4d158bf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
15 changes: 11 additions & 4 deletions MyNCMusic/Helper/LoginHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ public static class LoginHelper
/// <returns></returns>
public static LoginRoot LoginAccount()
{
if (Http.cookies!=null&&Http.cookies.GetCookies(new Uri(ConfigService.ApiUri + "/login")).Count != 0)//存在cookies,检查登陆状态
try
{
var status = GetLoginStatus();
if (status != null && status.Data.account !=null)
return status.Data;
if (Http.cookies != null && Http.cookies.GetCookies(new Uri(ConfigService.ApiUri + "/login")) != null && Http.cookies.GetCookies(new Uri(ConfigService.ApiUri + "/login")).Count != 0)//存在cookies,检查登陆状态
{
var status = GetLoginStatus();
if (status != null && status.Data.account != null)
return status.Data;
}
}
catch(NullReferenceException)//上一次请求出错后记录了错误的cookie,再次读取会引发null错误
{
Http.cookies = null;
}
if (Http.cookies == null)
Http.cookies = new System.Net.CookieContainer();
Expand Down
5 changes: 3 additions & 2 deletions MyNCMusic/MyNCMusic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<PackageCertificateKeyFile>C:\Users\29987\source\repos\MyNCMusic\MyNCMusic\MyNCMusic_TemporaryKey.pfx</PackageCertificateKeyFile>
<PackageCertificateThumbprint>A7388FF8C875A3428868B2AAB048E42EE6C659AD</PackageCertificateThumbprint>
<PackageCertificateKeyFile>
</PackageCertificateKeyFile>
<PackageCertificateThumbprint>21671089A53989417F2962B3F4521E9FE52853CF</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
Expand Down
2 changes: 1 addition & 1 deletion MyNCMusic/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Identity
Name="QEDSD.MyNCMusic"
Publisher="CN=QEDSD"
Version="1.0.2.0" />
Version="1.0.3.0" />

<mp:PhoneIdentity PhoneProductId="211dfa3c-48a9-4219-ae7f-0cf2f059a970" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down

0 comments on commit 4d158bf

Please sign in to comment.