Skip to content

Commit 91c6de1

Browse files
committed
合并代码
2 parents 6ab9382 + 05b0eeb commit 91c6de1

File tree

5 files changed

+65
-27
lines changed

5 files changed

+65
-27
lines changed

README.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 🤣阿星Plus⭐⭐⭐ 个人博客
1+
# 🤣阿星Plus⭐⭐⭐ 个人博客
22

33
## 项目介绍
44

@@ -8,6 +8,24 @@
88

99
If you liked `Blog` project or if it helped you, please give a star ⭐️ for this repository. 👍👍👍
1010

11+
```tree
12+
blog
13+
├── assets ---------- assets
14+
├── LICENSE ---------- LICENSE
15+
├── meowv.blog.sln ---------- Solution
16+
├── README.md ---------- README.md
17+
└── src
18+
├── Meowv.Blog.Admin ---------- Admin项目 admin.meowv.com
19+
├── Meowv.Blog.Api ---------- Api项目 api.meowv.com
20+
├── Meowv.Blog.Application ---------- Application
21+
├── Meowv.Blog.BackgroundWorkers ---------- BackgroundWorkers
22+
├── Meowv.Blog.Core ---------- Core
23+
├── Meowv.Blog.DbMigrator ---------- DbMigrator
24+
├── Meowv.Blog.MongoDb ---------- MongoDb
25+
├── Meowv.Blog.Response ---------- Response
26+
└── Meowv.Blog.Web ---------- Web项目 meowv.com
27+
```
28+
1129
## 预览体验
1230

1331
### Web项目:[https://meowv.com](https://meowv.com)
@@ -30,6 +48,8 @@ If you liked `Blog` project or if it helped you, please give a star ⭐️ for t
3048

3149
## [文章介绍](https://docs.meowv.com/aspnetcore/abp-blog/)
3250

51+
### v3.4.0
52+
3353
1. **[使用 abp cli 搭建项目](https://mp.weixin.qq.com/s/3Sc4Z2xkLdQNErvXf92B9A)**
3454
2. **[给项目瘦身,让它跑起来](https://mp.weixin.qq.com/s/oc96GG2sxz0J_vT6sReojQ)**
3555
3. **[完善与美化,Swagger登场](https://mp.weixin.qq.com/s/usz1BRYzBO2tT_z9MaonPg)**
@@ -61,23 +81,9 @@ If you liked `Blog` project or if it helped you, please give a star ⭐️ for t
6181
29. **[Blazor 实战系列(九)](https://mp.weixin.qq.com/s/0-mMmkr3HelmoJUWN7R7JA)**
6282
30. **[终结篇之发布项目](https://mp.weixin.qq.com/s/Lf543XOxSIGYdOGM8Zt4Lw)**
6383

64-
```tree
65-
blog
66-
├── assets ---------- assets
67-
├── LICENSE ---------- LICENSE
68-
├── meowv.blog.sln ---------- Solution
69-
├── README.md ---------- README.md
70-
└── src
71-
├── Meowv.Blog.Admin ---------- Admin项目 admin.meowv.com
72-
├── Meowv.Blog.Api ---------- Api项目 api.meowv.com
73-
├── Meowv.Blog.Application ---------- Application
74-
├── Meowv.Blog.BackgroundWorkers ---------- BackgroundWorkers
75-
├── Meowv.Blog.Core ---------- Core
76-
├── Meowv.Blog.DbMigrator ---------- DbMigrator
77-
├── Meowv.Blog.MongoDb ---------- MongoDb
78-
├── Meowv.Blog.Response ---------- Response
79-
└── Meowv.Blog.Web ---------- Web项目 meowv.com
80-
```
84+
### v4.0.0
85+
86+
TODO...
8187

8288
## LICENSE
8389

src/Meowv.Blog.Api/appsettings.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ authorize:
7474
redirectUrl: 'https://admin.meowv.com/oauth/weibo'
7575
scope: 'all'
7676
qq:
77-
clientId: '101931838'
77+
clientId: '101935194'
7878
clientSecret: ''
79-
redirectUrl: 'https://api.meowv.com/api/meowv/oauth/qq/token'
79+
redirectUrl: 'https://admin.meowv.com/oauth/qq'
8080
scope: 'get_user_info'

src/Meowv.Blog.Application/Authorize/OAuth/Impl/OAuthQQService.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public override async Task<User> GetUserByOAuthAsync(string type, string code, s
2424
var accessToken = await GetAccessTokenAsync(code, state);
2525
var userInfo = await GetUserInfoAsync(accessToken);
2626

27-
return await UserService.CreateUserAsync(userInfo.Email, type, userInfo.Id, userInfo.Name, userInfo.Avatar, userInfo.Email);
27+
return await UserService.CreateUserAsync(userInfo.Name, type, userInfo.Id, userInfo.Name, userInfo.Avatar, userInfo.Email);
2828
}
2929

3030
public override async Task<AccessTokenBase> GetAccessTokenAsync(string code, string state)
3131
{
3232
var param = BuildAccessTokenParams(code, state);
33-
Options.Value.AccessTokenUrl = $"{Options.Value.AccessTokenUrl}?{param.ToQueryStringWithEncode()}";
33+
Options.Value.AccessTokenUrl = $"{Options.Value.AccessTokenUrl}?{param.ToQueryString()}";
3434

3535
using var client = HttpClient.CreateClient();
3636
var response = await client.GetStringAsync(Options.Value.AccessTokenUrl);
@@ -47,12 +47,17 @@ public override async Task<QQUserInfo> GetUserInfoAsync(AccessTokenBase accessTo
4747
{
4848
using var client = HttpClient.CreateClient();
4949

50-
var openIdResponse = await client.GetStringAsync($"{Options.Value.OpenIdUrl}?access_token={accessToken.AccessToken}");
51-
50+
var openIdResponse = await client.GetStringAsync($"{Options.Value.OpenIdUrl}?access_token={accessToken.AccessToken}&fmt=json");
51+
var openId = openIdResponse.DeserializeToObject<QQOpenId>().OpenId;
52+
53+
var param = BuildUserInfoParams(accessToken.AccessToken, openId);
54+
Options.Value.UserInfoUrl = $"{Options.Value.UserInfoUrl}?{param.ToQueryString()}";
5255

5356
var response = await client.GetStringAsync(Options.Value.UserInfoUrl);
5457

5558
var userInfo = response.DeserializeToObject<QQUserInfo>();
59+
userInfo.Id = openId;
60+
5661
return userInfo;
5762
}
5863

@@ -80,5 +85,15 @@ protected Dictionary<string, string> BuildAccessTokenParams(string code, string
8085
["state"] = state
8186
};
8287
}
88+
89+
protected Dictionary<string, string> BuildUserInfoParams(string accessToken, string openId)
90+
{
91+
return new Dictionary<string, string>()
92+
{
93+
["access_token"] = accessToken,
94+
["oauth_consumer_key"] = Options.Value.ClientId,
95+
["openid"] = openId,
96+
};
97+
}
8398
}
8499
}

src/Meowv.Blog.Application/Users/Impl/UserService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public async Task<BlogResponse<UserDto>> GetCurrentUserAsync()
220220
[RemoteService(false)]
221221
public async Task<User> CreateUserAsync(string username, string type, string identity, string name, string avatar, string email)
222222
{
223-
var user = await _users.FindAsync(x => x.Username == username && x.Type == type && x.Identity == identity);
223+
var user = await _users.FindAsync(x => x.Type == type && x.Identity == identity);
224224
if (user is null)
225225
{
226226
await _users.InsertAsync(new User
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1-
namespace Meowv.Blog.Dto.Authorize
1+
using Newtonsoft.Json;
2+
3+
namespace Meowv.Blog.Dto.Authorize
24
{
3-
public class QQUserInfo : UserInfoBase
5+
public class QQUserInfo
46
{
7+
public string Id { get; set; }
8+
9+
[JsonProperty("nickname")]
10+
public string Name { get; set; }
11+
12+
[JsonProperty("figureurl_qq")]
13+
public string Avatar { get; set; }
14+
15+
public string Email { get; set; } = "";
16+
}
17+
18+
public class QQOpenId
19+
{
20+
[JsonProperty("openid")]
21+
public string OpenId { get; set; }
522
}
623
}

0 commit comments

Comments
 (0)