mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-28 04:36:38 +08:00
feat: 优化第三方登录结构
This commit is contained in:
@@ -19,9 +19,5 @@ public static class QQAuthenticationConstants
|
||||
public const string PictureMediumUrl = "urn:qq:picture_medium";
|
||||
public const string PictureUrl = "urn:qq:picture";
|
||||
public const string UnionId = "urn:qq:unionid";
|
||||
|
||||
public const string OpenId = "urn:openid";
|
||||
public const string AccessToken = "urn:access_token";
|
||||
public const string Name = "urn:name";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,6 @@ namespace Yi.Framework.AspNetCore.Authentication.OAuth.QQ
|
||||
|
||||
public override string AuthenticationSchemeNmae => QQAuthenticationDefaults.AuthenticationScheme;
|
||||
|
||||
protected override void VerifyErrResponse(string content)
|
||||
{
|
||||
QQAuthticationErrCodeModel.VerifyErrResponse(content);
|
||||
}
|
||||
|
||||
protected override async Task<List<Claim>> GetAuthTicketAsync(string code)
|
||||
{
|
||||
|
||||
@@ -58,9 +53,9 @@ namespace Yi.Framework.AspNetCore.Authentication.OAuth.QQ
|
||||
new Claim(Claims.PictureMediumUrl, userInfoMdoel.figureurl_qq_1),
|
||||
new Claim(Claims.PictureUrl, userInfoMdoel.figureurl),
|
||||
|
||||
new Claim(Claims.OpenId, tokenModel.openid),
|
||||
new Claim(Claims.Name, userInfoMdoel.nickname),
|
||||
new Claim(Claims.AccessToken, tokenModel.access_token),
|
||||
new Claim(AuthenticationConstants.OpenId, tokenModel.openid),
|
||||
new Claim(AuthenticationConstants.Name, userInfoMdoel.nickname),
|
||||
new Claim(AuthenticationConstants.AccessToken, tokenModel.access_token),
|
||||
|
||||
};
|
||||
return claims;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||
using static Yi.Framework.AspNetCore.Authentication.OAuth.QQ.QQAuthenticationConstants;
|
||||
|
||||
namespace Yi.Framework.AspNetCore.Authentication.OAuth.QQ;
|
||||
@@ -14,7 +13,7 @@ namespace Yi.Framework.AspNetCore.Authentication.OAuth.QQ;
|
||||
/// <summary>
|
||||
/// Defines a set of options used by <see cref="QQAuthenticationHandler"/>.
|
||||
/// </summary>
|
||||
public class QQAuthenticationOptions : OAuthOptions
|
||||
public class QQAuthenticationOptions : AuthenticationOAuthOptions
|
||||
{
|
||||
public QQAuthenticationOptions()
|
||||
{
|
||||
@@ -47,5 +46,4 @@ public class QQAuthenticationOptions : OAuthOptions
|
||||
/// </summary>
|
||||
public string UserIdentificationEndpoint { get; set; }
|
||||
|
||||
public string RedirectUri { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace Yi.Framework.AspNetCore.Authentication.OAuth.QQ
|
||||
{
|
||||
public class QQAuthticationErrCodeModel
|
||||
{
|
||||
public string error { get; set; }
|
||||
|
||||
public string error_description { get; set; }
|
||||
|
||||
public static void VerifyErrResponse(string content)
|
||||
{
|
||||
|
||||
var model =Newtonsoft.Json.JsonConvert.DeserializeObject <QQAuthticationErrCodeModel>(content);
|
||||
if (model.error != null)
|
||||
{
|
||||
|
||||
throw new Exception($"第三方授权返回错误,错误码:【{model.error}】,错误详情:【{model.error_description}】");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user