Browse Source

Merge pull request #1322 from colinin/work-weixin-code-bind

feat(oauth): Adjust the binding work weixin code
pull/1327/head
yx lin 5 months ago
committed by GitHub
parent
commit
893f290b20
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json
  2. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json
  3. 3
      aspnet-core/modules/account/LINGYUN.Abp.Account.OAuth/LINGYUN/Abp/Account/OAuth/Localization/Resources/en.json
  4. 3
      aspnet-core/modules/account/LINGYUN.Abp.Account.OAuth/LINGYUN/Abp/Account/OAuth/Localization/Resources/zh-Hans.json
  5. 10
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OAuth/Areas/Account/Controllers/Dtos/WorkWeixinLoginBindInput.cs
  6. 5
      aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OAuth/Areas/Account/Controllers/OAuthAccountController.cs

2
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json

@ -62,6 +62,8 @@
"Bind": "Bind",
"UnBind": "Unbound",
"CancelBind": "Cancel Bind",
"BindSuccessfully": "Binding successful!",
"CancelBindSuccessfully": "Unbinding successful!",
"CancelBindWarningMessage": "After unbinding, you will not be able to use an external identity. If you log in through this method, your session will be logged out!"
}
}

2
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json

@ -62,6 +62,8 @@
"Bind": "绑定",
"UnBind": "未绑定",
"CancelBind": "解除绑定",
"BindSuccessfully": "绑定成功!",
"CancelBindSuccessfully": "解除绑定成功!",
"CancelBindWarningMessage": "解除绑定后将无法使用外部身份,如果你通过此方式登录,你的会话将被注销!"
}
}

3
aspnet-core/modules/account/LINGYUN.Abp.Account.OAuth/LINGYUN/Abp/Account/OAuth/Localization/Resources/en.json

@ -31,6 +31,7 @@
"OAuth:QQ": "QQ",
"OAuth:Weixin": "WeChat",
"OAuth:WorkWeixin": "WeCom",
"OAuth:Bilibili": "Bilibili"
"OAuth:Bilibili": "Bilibili",
"WorkWeixin:Code": "Code"
}
}

3
aspnet-core/modules/account/LINGYUN.Abp.Account.OAuth/LINGYUN/Abp/Account/OAuth/Localization/Resources/zh-Hans.json

@ -31,6 +31,7 @@
"OAuth:QQ": "QQ",
"OAuth:Weixin": "微信",
"OAuth:WorkWeixin": "企业微信",
"OAuth:Bilibili": "Bilibili"
"OAuth:Bilibili": "Bilibili",
"WorkWeixin:Code": "授权码"
}
}

10
aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OAuth/Areas/Account/Controllers/Dtos/WorkWeixinLoginBindInput.cs

@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Abp.Account.Web.OAuth.Areas.Account.Controllers.Dtos;
public class WorkWeixinLoginBindInput
{
[Required]
[Display(Name = "WorkWeixin:Code")]
public string Code { get; set; }
}

5
aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OAuth/Areas/Account/Controllers/OAuthAccountController.cs

@ -1,4 +1,5 @@
using AspNet.Security.OAuth.WorkWeixin;
using LINGYUN.Abp.Account.Web.OAuth.Areas.Account.Controllers.Dtos;
using LINGYUN.Abp.WeChat.Work.Authorize;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
@ -27,9 +28,9 @@ public class OAuthAccountController : AbpController
[HttpPost]
[Authorize]
[Route("work-weixin/bind")]
public virtual async Task WorkWeixinLoginBindAsync(string code)
public virtual async Task WorkWeixinLoginBindAsync(WorkWeixinLoginBindInput input)
{
var workWeixinUser = await WeChatWorkUserFinder.GetUserInfoAsync(code);
var workWeixinUser = await WeChatWorkUserFinder.GetUserInfoAsync(input.Code);
var currentUser = await UserManager.GetByIdAsync(CurrentUser.GetId());
var userLogins = await UserManager.GetLoginsAsync(currentUser);
var workWexinLogin = userLogins.FirstOrDefault(x => x.LoginProvider == WorkWeixinAuthenticationDefaults.AuthenticationScheme);

Loading…
Cancel
Save