Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit bd5d405

Browse files
authored
修复二维码登录 (#1776)
1 parent 23706da commit bd5d405

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/Lib/SignIn.Uwp/AuthorizeProvider/AuthorizeProvider.Extension.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
using System;
44
using System.Collections.Generic;
5-
using System.Drawing.Imaging;
6-
using System.IO;
75
using System.Linq;
86
using System.Net.Http;
97
using System.Runtime.InteropServices.WindowsRuntime;
@@ -241,7 +239,7 @@ internal async Task<BitmapImage> GetQRImageAsync()
241239
{ Query.LocalId, _guid },
242240
};
243241
var httpProvider = Locator.Instance.GetService<IHttpProvider>();
244-
var request = await httpProvider.GetRequestMessageAsync(HttpMethod.Post, Passport.QRCode, queryParameters);
242+
var request = await httpProvider.GetRequestMessageAsync(HttpMethod.Post, Passport.QRCode, queryParameters, RequestClientType.Login);
245243
var response = await httpProvider.SendAsync(request);
246244
var result = await httpProvider.ParseAsync<ServerResponse<QRInfo>>(response);
247245

@@ -305,25 +303,19 @@ private async void OnQRTimerTickAsync(object sender, object e)
305303
{
306304
{ Query.AuthCode, _internalQRAuthCode },
307305
{ Query.LocalId, _guid },
306+
{ "guid", Guid.NewGuid().ToString() },
308307
};
309308

310309
try
311310
{
312311
var httpProvider = Locator.Instance.GetService<IHttpProvider>();
313-
var request = await httpProvider.GetRequestMessageAsync(HttpMethod.Post, Passport.QRCodeCheck, queryParameters);
312+
var request = await httpProvider.GetRequestMessageAsync(HttpMethod.Post, Passport.QRCodeCheck, queryParameters, RequestClientType.Login);
314313
var response = await httpProvider.SendAsync(request, _qrPollCancellationTokenSource.Token);
315314
var result = await httpProvider.ParseAsync<ServerResponse<TokenInfo>>(response);
316315

317316
// 保存cookie
318317
SaveCookie(result.Data.CookieInfo);
319-
320-
// 获取确认链接
321-
var confirmUrl = await GetCookieToAccessKeyConfirmUrlAsync();
322-
323-
// 获取新的访问令牌
324-
var accessKey = await GetAccessKeyAsync(confirmUrl);
325-
result.Data.AccessToken = accessKey;
326-
318+
SaveAuthorizeResult(result.Data);
327319
QRCodeStatusChanged?.Invoke(this, new Tuple<QRCodeStatus, TokenInfo>(QRCodeStatus.Success, result.Data));
328320
}
329321
catch (ServiceException se)
@@ -336,7 +328,7 @@ private async void OnQRTimerTickAsync(object sender, object e)
336328
if (se.Error != null)
337329
{
338330
QRCodeStatus qrStatus = default;
339-
if (se.Error.Code == 86039)
331+
if (se.Error.Code == 86039 || se.Error.Code == 86090)
340332
{
341333
qrStatus = QRCodeStatus.NotConfirm;
342334
}

src/Models/Models.App/Constants/ServiceConstants.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public static class Keys
4444
public const string IOSSecret = "c2ed53a74eeefe3cf99fbd01d8c9c375";
4545
public const string WebKey = "84956560bc028eb7";
4646
public const string WebSecret = "94aba54af9065f71de72f5508f1cd42e";
47-
public const string LoginKey = "4409e2ce8ffd12b8";
48-
public const string LoginSecret = "59b43e04ad6965f34319062b478f83dd";
47+
public const string LoginKey = "27eb53fc9058f8c3";
48+
public const string LoginSecret = "c2ed53a74eeefe3cf99fbd01d8c9c375";
4949
}
5050

5151
public static class Query

src/ViewModels/ViewModels.Uwp/Account/AccountViewModel/AccountViewModel.SignIn.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ private async Task<bool> InternalSignInAsync(bool isSlientOnly = false)
2828
if (isTokenValid)
2929
{
3030
isSuccess = true;
31+
State = AuthorizeState.SignedIn;
3132
HandleLogged();
3233
}
3334
else if (!isSlientOnly)
@@ -62,6 +63,13 @@ await _dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async
6263
State = AuthorizeState.SignedIn;
6364
});
6465
}
66+
else
67+
{
68+
await _dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
69+
{
70+
await SignOutAsync();
71+
});
72+
}
6573
});
6674
}
6775
}

0 commit comments

Comments
 (0)