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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with
21 additions and
4 deletions
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json
aspnet-core/modules/account/LINGYUN.Abp.Account.OAuth/LINGYUN/Abp/Account/OAuth/Localization/Resources/en.json
aspnet-core/modules/account/LINGYUN.Abp.Account.OAuth/LINGYUN/Abp/Account/OAuth/Localization/Resources/zh-Hans.json
aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OAuth/Areas/Account/Controllers/Dtos/WorkWeixinLoginBindInput.cs
aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OAuth/Areas/Account/Controllers/OAuthAccountController.cs
@ -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!"
}
}
@ -62,6 +62,8 @@
"Bind" : "绑定" ,
"UnBind" : "未绑定" ,
"CancelBind" : "解除绑定" ,
"BindSuccessfully" : "绑定成功!" ,
"CancelBindSuccessfully" : "解除绑定成功!" ,
"CancelBindWarningMessage" : "解除绑定后将无法使用外部身份,如果你通过此方式登录,你的会话将被注销!"
}
}
@ -31,6 +31,7 @@
"OAuth:QQ" : "QQ" ,
"OAuth:Weixin" : "WeChat" ,
"OAuth:WorkWeixin" : "WeCom" ,
"OAuth:Bilibili" : "Bilibili"
"OAuth:Bilibili" : "Bilibili" ,
"WorkWeixin:Code" : "Code"
}
}
@ -31,6 +31,7 @@
"OAuth:QQ" : "QQ" ,
"OAuth:Weixin" : "微信" ,
"OAuth:WorkWeixin" : "企业微信" ,
"OAuth:Bilibili" : "Bilibili"
"OAuth:Bilibili" : "Bilibili" ,
"WorkWeixin:Code" : "授权码"
}
}
@ -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 ; }
}
@ -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 ( c ode) ;
var workWeixinUser = await WeChatWorkUserFinder . GetUserInfoAsync ( input . C ode) ;
var currentUser = await UserManager . GetByIdAsync ( CurrentUser . GetId ( ) ) ;
var userLogins = await UserManager . GetLoginsAsync ( currentUser ) ;
var workWexinLogin = userLogins . FirstOrDefault ( x = > x . LoginProvider = = WorkWeixinAuthenticationDefaults . AuthenticationScheme ) ;