|
|
|
@ -41,7 +41,7 @@ namespace Shentun.WebPeis.Controllers |
|
|
|
} |
|
|
|
[IgnoreAntiforgeryToken] |
|
|
|
[ApiExplorerSettings(IgnoreApi = true)] |
|
|
|
public class WeChatController : AbpOpenIdDictControllerBase, ITokenExtensionGrant, IWeChatController,ITransientDependency |
|
|
|
public class WeChatController : AbpOpenIdDictControllerBase, ITokenExtensionGrant, IWeChatController, ITransientDependency |
|
|
|
{ |
|
|
|
|
|
|
|
private readonly IConfiguration _configuration; |
|
|
|
@ -83,7 +83,7 @@ namespace Shentun.WebPeis.Controllers |
|
|
|
ClientSecret = context.Request.GetParameter("client_secret").ToString(), |
|
|
|
}; |
|
|
|
var clientCredentialsResult = await httpClient.RequestClientCredentialsTokenAsync(request); |
|
|
|
if(clientCredentialsResult.IsError) |
|
|
|
if (clientCredentialsResult.IsError) |
|
|
|
{ |
|
|
|
throw new Exception("应用程序没有权限" + clientCredentialsResult.ErrorDescription); |
|
|
|
} |
|
|
|
@ -121,11 +121,11 @@ namespace Shentun.WebPeis.Controllers |
|
|
|
{ |
|
|
|
throw new Exception("用户不存在"); |
|
|
|
} |
|
|
|
if(!user.IsActive) |
|
|
|
if (!user.IsActive) |
|
|
|
{ |
|
|
|
throw new Exception("用户已被禁用"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
principal = await SignInManager.CreateUserPrincipalAsync(user); |
|
|
|
if (principal == null) |
|
|
|
{ |
|
|
|
@ -177,13 +177,15 @@ namespace Shentun.WebPeis.Controllers |
|
|
|
}); |
|
|
|
await _unitOfWorkManager.Current.CompleteAsync(); |
|
|
|
var authenticationProperties = new AuthenticationProperties(); |
|
|
|
|
|
|
|
|
|
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false)) |
|
|
|
{ |
|
|
|
//return SignIn(principal, authenticationProperties, wechatSession.OpenId);
|
|
|
|
return SignIn(principal, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); |
|
|
|
var result = SignIn(principal, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme); |
|
|
|
await unitOfWork.CompleteAsync(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
|