Skip to content

Commit

Permalink
'加插件,qq微信登录,微信支付宝支付'
Browse files Browse the repository at this point in the history
  • Loading branch information
rock007 committed Jun 13, 2020
1 parent f0ed46c commit d145c7a
Show file tree
Hide file tree
Showing 192 changed files with 12,706 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Libraries/Nop.Core/Domain/Orders/Order.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Nop.Core.Domain.Payments;
using Nop.Core.Domain.Shipping;
using Nop.Core.Domain.Tax;
Expand Down Expand Up @@ -333,5 +334,6 @@ public TaxDisplayType CustomerTaxDisplayType
}

#endregion

}
}
60 changes: 60 additions & 0 deletions src/NopCommerce.sln
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.Payments.PayPalS
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.Widgets.FacebookPixel", "Plugins\Nop.Plugin.Widgets.FacebookPixel\Nop.Plugin.Widgets.FacebookPixel.csproj", "{87013DC8-D032-465B-A950-753E4EB15502}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.Payments.AliPay", "Plugins\Nop.Plugin.Payments.AliPay\Nop.Plugin.Payments.AliPay.csproj", "{F5F6B2C0-8C5F-470A-B611-8DB79976915B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.ExternalAuth.QQ", "Plugins\Nop.Plugin.ExternalAuth.QQ\Nop.Plugin.ExternalAuth.QQ.csproj", "{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.Payments.WeChatPay", "Plugins\Nop.Plugin.Payments.WeChatPay\Nop.Plugin.Payments.WeChatPay.csproj", "{5050A0F8-AB94-49E8-946F-D84780593818}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nop.Plugin.ExternalAuth.WeChat", "Plugins\Nop.Plugin.ExternalAuth.WeChat\Nop.Plugin.ExternalAuth.WeChat.csproj", "{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -353,6 +361,54 @@ Global
{87013DC8-D032-465B-A950-753E4EB15502}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{87013DC8-D032-465B-A950-753E4EB15502}.Release|x86.ActiveCfg = Release|Any CPU
{87013DC8-D032-465B-A950-753E4EB15502}.Release|x86.Build.0 = Release|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Debug|x86.ActiveCfg = Debug|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Debug|x86.Build.0 = Debug|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Release|Any CPU.Build.0 = Release|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Release|x86.ActiveCfg = Release|Any CPU
{F5F6B2C0-8C5F-470A-B611-8DB79976915B}.Release|x86.Build.0 = Release|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Debug|x86.ActiveCfg = Debug|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Debug|x86.Build.0 = Debug|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Release|Any CPU.Build.0 = Release|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Release|x86.ActiveCfg = Release|Any CPU
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C}.Release|x86.Build.0 = Release|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Debug|x86.ActiveCfg = Debug|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Debug|x86.Build.0 = Debug|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Release|Any CPU.Build.0 = Release|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Release|x86.ActiveCfg = Release|Any CPU
{5050A0F8-AB94-49E8-946F-D84780593818}.Release|x86.Build.0 = Release|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Debug|x86.ActiveCfg = Debug|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Debug|x86.Build.0 = Debug|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Release|Any CPU.Build.0 = Release|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Release|x86.ActiveCfg = Release|Any CPU
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -384,6 +440,10 @@ Global
{83F05E8D-2D6C-41FC-A95C-9621ED358615} = {7881B112-7843-4542-B1F7-F99553FB9BB7}
{FAC5F9D0-2C2B-4296-B079-E723EA8A320C} = {7881B112-7843-4542-B1F7-F99553FB9BB7}
{87013DC8-D032-465B-A950-753E4EB15502} = {7881B112-7843-4542-B1F7-F99553FB9BB7}
{F5F6B2C0-8C5F-470A-B611-8DB79976915B} = {7881B112-7843-4542-B1F7-F99553FB9BB7}
{9B3A0755-EE75-4D6F-AC8F-6FCB1A7CC46C} = {7881B112-7843-4542-B1F7-F99553FB9BB7}
{5050A0F8-AB94-49E8-946F-D84780593818} = {7881B112-7843-4542-B1F7-F99553FB9BB7}
{8FAD4083-93B2-48B3-AC53-6F1545FA1C83} = {7881B112-7843-4542-B1F7-F99553FB9BB7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EE72A8B2-332A-4175-9319-6726D36E9D25}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Mvc;
using Nop.Plugin.ExternalAuth.QQ;
using Nop.Web.Framework.Components;

namespace Nop.Plugin.ExternalAuth.Facebook.Components
{
[ViewComponent(Name = QQAuthenticationDefaults.ViewComponentName)]
public class QQAuthenticationViewComponent : NopViewComponent
{
public IViewComponentResult Invoke()
{
return View("~/Plugins/ExternalAuth.QQ/Views/PublicInfo.cshtml");
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions src/Plugins/Nop.Plugin.ExternalAuth.QQ/Content/qqstyles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.qq-btn {
display: inline-block;
width: 150px;
height: 23px;
background-image: url('images/qq.png');
background-repeat: no-repeat;
}
.qq-btn:hover {
background-position: 0px -24px;
}
.qq-btn:active {
background-position: 0px -48px;
}

/* */
.fl { float: left; }
.select-login-type { margin-top: 43px;}
.select-login-type a {
display: inline-block;
border-radius: 50%;
width: 165px;
height: 165px;
border: 1px solid #dfdfdf;
font-size: 18px;
text-align: center;
}
.select-login-type a em {
margin: 38px auto 13px;
display: block;
background-image: url('images/login-type.png');
background-repeat: no-repeat;
}
.select-login-type .qq {
color: #2a9ce3;
margin-left: 97px;
margin-right: 40px;
}
.select-login-type .qq em {
width: 52px;
height: 57px;
background-position: -11px -6px;
}
.select-login-type .qq:hover {
background: #2a9ce3;
color: #fff;
border: 1px solid #2a9ce3;
}
.select-login-type .wechat {
color: #40af37;
margin-left: 40px;
}
.select-login-type .wechat:hover {
background: #40af37;
color: #fff;
border: 1px solid #40af37;
}

.select-login-type .wechat em {
width: 57px;
height: 57px;
background-position: -124px -6px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
//using Microsoft.AspNetCore.Authentication.Facebook;
using Microsoft.AspNetCore.Authentication.QQ;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Nop.Core;
using Nop.Plugin.ExternalAuth.QQ.Models;
using Nop.Services.Authentication.External;
using Nop.Services.Configuration;
using Nop.Services.Localization;
using Nop.Services.Security;
using Nop.Web.Framework;
using Nop.Web.Framework.Controllers;
using Nop.Web.Framework.Mvc.Filters;

namespace Nop.Plugin.ExternalAuth.QQ.Controllers
{
public partial class QQAuthenticationController : BasePluginController
{
#region Methods

public IActionResult Login(string returnUrl)
{

/***!!
if (!_externalAuthenticationService.ExternalAuthenticationMethodIsAvailable(QQAuthenticationDefaults.ProviderSystemName))
throw new NopException("QQ authentication module cannot be loaded");
***/

if (string.IsNullOrEmpty(_qqExternalAuthSettings.ClientKeyIdentifier) || string.IsNullOrEmpty(_qqExternalAuthSettings.ClientSecret))
throw new NopException("QQ authentication module not configured");

//configure login callback action
var authenticationProperties = new AuthenticationProperties
{
RedirectUri = Url.Action("LoginCallback", "QQAuthentication", new { returnUrl = returnUrl })
};
authenticationProperties.SetString("ErrorCallback", Url.RouteUrl("Login", new { returnUrl }));

return Challenge(authenticationProperties, QQDefaults.AuthenticationScheme);
}

public async Task<IActionResult> LoginCallback(string returnUrl)
{
//authenticate QQ user
var authenticateResult = await HttpContext.AuthenticateAsync(QQDefaults.AuthenticationScheme);
if (!authenticateResult.Succeeded || !authenticateResult.Principal.Claims.Any())
return RedirectToRoute("Login");

//create external authentication parameters
var authenticationParameters = new ExternalAuthenticationParameters
{
ProviderSystemName = QQAuthenticationDefaults.ProviderSystemName,
AccessToken = await HttpContext.GetTokenAsync(QQDefaults.AuthenticationScheme, "access_token"),
Email = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Email)?.Value,
ExternalIdentifier = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.NameIdentifier)?.Value,
ExternalDisplayIdentifier = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Name)?.Value,
Claims = authenticateResult.Principal.Claims.Select(claim => new ExternalAuthenticationClaim(claim.Type, claim.Value)).ToList()
};

//authenticate Nop user
return _externalAuthenticationService.Authenticate(authenticationParameters, returnUrl);
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using Microsoft.AspNetCore.Authentication.QQ;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Nop.Plugin.ExternalAuth.QQ.Models;
using Nop.Services.Authentication.External;
using Nop.Services.Configuration;
using Nop.Services.Localization;
using Nop.Services.Messages;
using Nop.Services.Security;
using Nop.Web.Framework;
using Nop.Web.Framework.Controllers;
using Nop.Web.Framework.Mvc.Filters;

namespace Nop.Plugin.ExternalAuth.QQ.Controllers
{
public partial class QQAuthenticationController : BasePluginController
{
#region Fields

private readonly QQExternalAuthSettings _qqExternalAuthSettings;
private readonly IExternalAuthenticationService _externalAuthenticationService;
private readonly ILocalizationService _localizationService;
private readonly IOptionsMonitorCache<QQOptions> _optionsCache;
private readonly IPermissionService _permissionService;
private readonly ISettingService _settingService;
private readonly INotificationService _notificationService;

#endregion

#region Ctor

public QQAuthenticationController(QQExternalAuthSettings qqExternalAuthSettings,
IExternalAuthenticationService externalAuthenticationService,
ILocalizationService localizationService,
INotificationService notificationService,
IOptionsMonitorCache<QQOptions> optionsCache,
IPermissionService permissionService,
ISettingService settingService)
{
this._qqExternalAuthSettings = qqExternalAuthSettings;
this._externalAuthenticationService = externalAuthenticationService;
this._localizationService = localizationService;
this._optionsCache = optionsCache;
this._permissionService = permissionService;
this._settingService = settingService;
_notificationService = notificationService;
}

#endregion

#region Methods

[AuthorizeAdmin]
[Area(AreaNames.Admin)]
public IActionResult Configure()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageExternalAuthenticationMethods))
return AccessDeniedView();

var model = new ConfigurationModel
{
ClientId = _qqExternalAuthSettings.ClientKeyIdentifier,
ClientSecret = _qqExternalAuthSettings.ClientSecret
};

return View("~/Plugins/ExternalAuth.QQ/Views/Configure.cshtml", model);
}

[HttpPost]
//[AdminAntiForgery]
[AuthorizeAdmin]
[Area(AreaNames.Admin)]
public IActionResult Configure(ConfigurationModel model)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageExternalAuthenticationMethods))
return AccessDeniedView();

if (!ModelState.IsValid)
return Configure();

//save settings
_qqExternalAuthSettings.ClientKeyIdentifier = model.ClientId;
_qqExternalAuthSettings.ClientSecret = model.ClientSecret;
_settingService.SaveSetting(_qqExternalAuthSettings);

//clear QQ authentication options cache
_optionsCache.TryRemove(QQDefaults.AuthenticationScheme);

_notificationService.SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));

return Configure();
}


#endregion
}
}
Loading

0 comments on commit d145c7a

Please sign in to comment.