コード例 #1
0
        public async Task <IActionResult> Configure()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePaymentMethods))
            {
                return(AccessDeniedView());
            }

            //load settings for a chosen store scope
            var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync();

            var manualPaymentSettings = await _settingService.LoadSettingAsync <ManualPaymentSettings>(storeScope);

            var model = new ConfigurationModel
            {
                TransactModeId                = Convert.ToInt32(manualPaymentSettings.TransactMode),
                AdditionalFee                 = manualPaymentSettings.AdditionalFee,
                AdditionalFeePercentage       = manualPaymentSettings.AdditionalFeePercentage,
                TransactModeValues            = await manualPaymentSettings.TransactMode.ToSelectListAsync(),
                ActiveStoreScopeConfiguration = storeScope
            };

            if (storeScope > 0)
            {
                model.TransactModeId_OverrideForStore = await _settingService.SettingExistsAsync(manualPaymentSettings, x => x.TransactMode, storeScope);

                model.AdditionalFee_OverrideForStore = await _settingService.SettingExistsAsync(manualPaymentSettings, x => x.AdditionalFee, storeScope);

                model.AdditionalFeePercentage_OverrideForStore = await _settingService.SettingExistsAsync(manualPaymentSettings, x => x.AdditionalFeePercentage, storeScope);
            }

            return(View("~/Plugins/Payments.Manual/Views/Configure.cshtml", model));
        }
コード例 #2
0
        public async Task <IActionResult> LogList(TaxTransactionLogSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageTaxSettings))
            {
                return(await AccessDeniedDataTablesJson());
            }

            //prepare filter parameters
            var createdFromValue = searchModel.CreatedFrom.HasValue
                ? (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.CreatedFrom.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync())
                : null;
            var createdToValue = searchModel.CreatedTo.HasValue
                ? (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.CreatedTo.Value, await _dateTimeHelper.GetCurrentTimeZoneAsync()).AddDays(1)
                : null;

            //get tax transaction log
            var taxtransactionLog = await _taxTransactionLogService.GetTaxTransactionLogAsync(createdFromUtc : createdFromValue, createdToUtc : createdToValue,
                                                                                              pageIndex : searchModel.Page - 1, pageSize : searchModel.PageSize);

            //prepare grid model
            var model = await new TaxTransactionLogListModel().PrepareToGridAsync(searchModel, taxtransactionLog, () =>
            {
                return(taxtransactionLog.SelectAwait(async logItem => new TaxTransactionLogModel
                {
                    Id = logItem.Id,
                    StatusCode = logItem.StatusCode,
                    Url = logItem.Url,
                    CustomerId = logItem.CustomerId,
                    CreatedDate = await _dateTimeHelper.ConvertToUserTimeAsync(logItem.CreatedDateUtc, DateTimeKind.Utc)
                }));
            });

            return(Json(model));
        }
コード例 #3
0
        public async Task <IActionResult> Configure()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePaymentMethods))
            {
                return(AccessDeniedView());
            }

            //load settings for a chosen store scope
            var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync();

            var purchaseOrderPaymentSettings = await _settingService.LoadSettingAsync <PurchaseOrderPaymentSettings>(storeScope);

            var model = new ConfigurationModel
            {
                AdditionalFee                 = purchaseOrderPaymentSettings.AdditionalFee,
                AdditionalFeePercentage       = purchaseOrderPaymentSettings.AdditionalFeePercentage,
                ShippableProductRequired      = purchaseOrderPaymentSettings.ShippableProductRequired,
                ActiveStoreScopeConfiguration = storeScope
            };

            if (storeScope > 0)
            {
                model.AdditionalFee_OverrideForStore = await _settingService.SettingExistsAsync(purchaseOrderPaymentSettings, x => x.AdditionalFee, storeScope);

                model.AdditionalFeePercentage_OverrideForStore = await _settingService.SettingExistsAsync(purchaseOrderPaymentSettings, x => x.AdditionalFeePercentage, storeScope);

                model.ShippableProductRequired_OverrideForStore = await _settingService.SettingExistsAsync(purchaseOrderPaymentSettings, x => x.ShippableProductRequired, storeScope);
            }

            return(View("~/Plugins/Payments.PurchaseOrder/Views/Configure.cshtml", model));
        }
コード例 #4
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> Methods(bool showtour = false)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePaymentMethods))
            {
                return(AccessDeniedView());
            }

            //prepare model
            var model = await _paymentModelFactory.PreparePaymentMethodsModelAsync(new PaymentMethodsModel());

            //show configuration tour
            if (showtour)
            {
                var hideCard = await _genericAttributeService.GetAttributeAsync <bool>(await _workContext.GetCurrentCustomerAsync(), NopCustomerDefaults.HideConfigurationStepsAttribute);

                var closeCard = await _genericAttributeService.GetAttributeAsync <bool>(await _workContext.GetCurrentCustomerAsync(), NopCustomerDefaults.CloseConfigurationStepsAttribute);

                if (!hideCard && !closeCard)
                {
                    ViewBag.ShowTour = true;
                }
            }

            return(View(model));
        }
コード例 #5
0
ファイル: CatalogController.cs プロジェクト: Sakchai/eStore
        public virtual async Task <IActionResult> Category(int categoryId, CatalogProductsCommand command)
        {
            var category = await _categoryService.GetCategoryByIdAsync(categoryId);

            if (!await CheckCategoryAvailabilityAsync(category))
            {
                return(InvokeHttp404());
            }

            //'Continue shopping' URL
            await _genericAttributeService.SaveAttributeAsync(await _workContext.GetCurrentCustomerAsync(),
                                                              NopCustomerDefaults.LastContinueShoppingPageAttribute,
                                                              _webHelper.GetThisPageUrl(false),
                                                              (await _storeContext.GetCurrentStoreAsync()).Id);

            //display "edit" (manage) link
            if (await _permissionService.AuthorizeAsync(StandardPermissionProvider.AccessAdminPanel) && await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCategories))
            {
                DisplayEditLink(Url.Action("Edit", "Category", new { id = category.Id, area = AreaNames.Admin }));
            }

            //activity log
            await _customerActivityService.InsertActivityAsync("PublicStore.ViewCategory",
                                                               string.Format(await _localizationService.GetResourceAsync("ActivityLog.PublicStore.ViewCategory"), category.Name), category);

            //model
            var model = await _catalogModelFactory.PrepareCategoryModelAsync(category, command);

            //template
            var templateViewPath = await _catalogModelFactory.PrepareCategoryTemplateViewPathAsync(category.CategoryTemplateId);

            return(View(templateViewPath, model));
        }
コード例 #6
0
        public async Task <IActionResult> Configure()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }

            var storeId = await _storeContext.GetActiveStoreScopeConfigurationAsync();

            var settings = await _settingService.LoadSettingAsync <AccessiBeSettings>(storeId);

            var widgetSettings = await _settingService.LoadSettingAsync <WidgetSettings>(storeId);

            var model = new ConfigurationModel
            {
                Script  = settings.Script,
                Enabled = widgetSettings.ActiveWidgetSystemNames.Contains(AccessiBeDefaults.SystemName),
                ActiveStoreScopeConfiguration = storeId
            };

            if (storeId > 0)
            {
                model.Script_OverrideForStore = await _settingService.SettingExistsAsync(settings, setting => setting.Script, storeId);

                model.Enabled_OverrideForStore = await _settingService.SettingExistsAsync(widgetSettings, setting => setting.ActiveWidgetSystemNames, storeId);
            }

            //prepare store URL
            model.Url = storeId > 0
                ? (await _storeService.GetStoreByIdAsync(storeId))?.Url
                : _webHelper.GetStoreLocation();

            return(View("~/Plugins/Widgets.AccessiBe/Views/Configure.cshtml", model));
        }
コード例 #7
0
        public async Task <IActionResult> Configure(int discountId, int?discountRequirementId)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageDiscounts))
            {
                return(Content("Access denied"));
            }

            var discount = await _discountService.GetDiscountByIdAsync(discountId);

            if (discount == null)
            {
                throw new ArgumentException("Discount could not be loaded");
            }

            //check whether the discount requirement exists
            if (discountRequirementId.HasValue && await _discountService.GetDiscountRequirementByIdAsync(discountRequirementId.Value) is null)
            {
                return(Content("Failed to load requirement."));
            }

            var restrictedProductIds = await _settingService.GetSettingByKeyAsync <string>(string.Format(DiscountRequirementDefaults.SETTINGS_KEY, discountRequirementId ?? 0));

            var model = new RequirementModel
            {
                RequirementId = discountRequirementId ?? 0,
                DiscountId    = discountId,
                ProductIds    = restrictedProductIds
            };

            //add a prefix
            ViewData.TemplateInfo.HtmlFieldPrefix = string.Format(DiscountRequirementDefaults.HTML_FIELD_PREFIX, discountRequirementId ?? 0);

            return(View("~/Plugins/DiscountRules.HasAllProducts/Views/Configure.cshtml", model));
        }
コード例 #8
0
        public async Task <IActionResult> Configure()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }

            //load settings for a chosen store scope
            var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync();

            var helloWorldSettings = await _settingService.LoadSettingAsync <HelloWorldSettings>(storeScope);

            var model = new ConfigurationModel
            {
                Text = helloWorldSettings.Text,
                ActiveStoreScopeConfiguration = storeScope
            };

            if (storeScope > 0)
            {
                model.Text_OverrideForStore = await _settingService.SettingExistsAsync(helloWorldSettings, x => x.Text, storeScope);
            }

            return(View("~/Plugins/Widgets.HelloWorld/Views/Configure.cshtml", model));
        }
コード例 #9
0
        public async Task <IActionResult> Permissions()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageAcl))
            {
                return(AccessDeniedView());
            }

            var model = await _securityModelFactory.PreparePermissionRolesModel(new PermissionRolesModel());

            return(View(model));
        }
コード例 #10
0
        public async Task <IActionResult> Index()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageUsers))
            {
                return(AccessDeniedView());
            }

            var model = await _roleModelFactory.PrepareRoleSearchModel(new RoleSearchModel());

            return(View(model));
        }
コード例 #11
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> List()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePlugins))
            {
                return(AccessDeniedView());
            }

            var model = await _pluginModelFactory.PreparePluginSearchModelAsync(new PluginSearchModel());

            return(View(model));
        }
コード例 #12
0
        public async Task <IActionResult> Index()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageReports))
            {
                return(AccessDeniedView());
            }

            var model = await _reportModelFactory.PrepareReportContainerModel(new ReportContainerModel());

            return(View(model));
        }
コード例 #13
0
ファイル: CommonController.cs プロジェクト: hfz-r/mynews-sms
        public async Task <IActionResult> SystemInfo()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            var model = await _commonModelFactory.PrepareSystemInfoModel(new SystemInfoModel());

            return(View(model));
        }
コード例 #14
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> List()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
            {
                return(AccessDeniedView());
            }

            //prepare model
            var model = await _customerModelFactory.PrepareOnlineCustomerSearchModelAsync(new OnlineCustomerSearchModel());

            return(View(model));
        }
コード例 #15
0
        public async Task <IActionResult> Index()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePlugins))
            {
                return(AccessDeniedView());
            }

            //prepare model
            var model = await _apiSettingModelFactory.PrepareApiSettingsModel();

            return(View(ViewNames.ApiSettings, model));
        }
コード例 #16
0
        public virtual async Task <IActionResult> SendNotification()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
            {
                return(AccessDeniedView());
            }

            //prepare model
            var model = new PushNotificationModel();

            return(View(model));
        }
コード例 #17
0
        public virtual async Task <IActionResult> CurrentCarts()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCurrentCarts))
            {
                return(AccessDeniedView());
            }

            //prepare model
            var model = await _shoppingCartModelFactory.PrepareShoppingCartSearchModelAsync(new ShoppingCartSearchModel());

            return(View(model));
        }
        public async Task <IActionResult> Configure()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePaymentMethods))
            {
                return(AccessDeniedView());
            }

            //load settings for a chosen store scope
            var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync();

            var yuansferPaymentSettings = await _settingService.LoadSettingAsync <YuansferPaymentSettings>(storeScope);

            var model = new ConfigurationModel
            {
                ActiveStoreScopeConfiguration = storeScope,
                BaseApiUrl               = yuansferPaymentSettings.BaseApiUrl,
                MerchantId               = yuansferPaymentSettings.MerchantId,
                StoreId                  = yuansferPaymentSettings.StoreId,
                ApiToken                 = yuansferPaymentSettings.ApiToken,
                PaymentChannels          = yuansferPaymentSettings.PaymentChannels,
                AdditionalFee            = yuansferPaymentSettings.AdditionalFee,
                AdditionalFeePercentage  = yuansferPaymentSettings.AdditionalFeePercentage,
                AvailablePaymentChannels = Defaults.AvailablePaymentChannels
            };

            if (storeScope > 0)
            {
                model.BaseApiUrl_OverrideForStore = await _settingService.SettingExistsAsync(yuansferPaymentSettings, x => x.BaseApiUrl, storeScope);

                model.MerchantId_OverrideForStore = await _settingService.SettingExistsAsync(yuansferPaymentSettings, x => x.MerchantId, storeScope);

                model.StoreId_OverrideForStore = await _settingService.SettingExistsAsync(yuansferPaymentSettings, x => x.StoreId, storeScope);

                model.ApiToken_OverrideForStore = await _settingService.SettingExistsAsync(yuansferPaymentSettings, x => x.ApiToken, storeScope);

                model.PaymentChannels_OverrideForStore = await _settingService.SettingExistsAsync(yuansferPaymentSettings, x => x.PaymentChannels, storeScope);

                model.AdditionalFee_OverrideForStore = await _settingService.SettingExistsAsync(yuansferPaymentSettings, x => x.AdditionalFee, storeScope);

                model.AdditionalFeePercentage_OverrideForStore = await _settingService.SettingExistsAsync(yuansferPaymentSettings, x => x.AdditionalFeePercentage, storeScope);
            }

            //prices and total aren't rounded, so display warning
            if (!_shoppingCartSettings.RoundPricesDuringCalculation)
            {
                var url     = Url.Action("AllSettings", "Setting", new { settingName = nameof(ShoppingCartSettings.RoundPricesDuringCalculation) });
                var warning = string.Format(await _localizationService.GetResourceAsync("Plugins.Payments.Yuansfer.RoundingWarning"), url);
                _notificationService.WarningNotification(warning, false);
            }

            return(View("~/Plugins/Payments.Yuansfer/Views/Configure.cshtml", model));
        }
コード例 #19
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> Methods()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageExternalAuthenticationMethods))
            {
                return(AccessDeniedView());
            }

            //prepare model
            var model = _externalAuthenticationMethodModelFactory
                        .PrepareExternalAuthenticationMethodSearchModel(new ExternalAuthenticationMethodSearchModel());

            return(View(model));
        }
コード例 #20
0
        public virtual async Task <IActionResult> Category(int categoryId, CatalogPagingFilteringModel command)
        {
            var category = await _categoryService.GetCategoryByIdAsync(categoryId);

            if (category == null || category.Deleted)
            {
                return(InvokeHttp404());
            }

            var notAvailable =
                //published?
                !category.Published ||
                //ACL (access control list)
                !await _aclService.AuthorizeAsync(category) ||
                //Store mapping
                !await _storeMappingService.AuthorizeAsync(category);

            //Check whether the current user has a "Manage categories" permission (usually a store owner)
            //We should allows him (her) to use "Preview" functionality
            var hasAdminAccess = await _permissionService.AuthorizeAsync(StandardPermissionProvider.AccessAdminPanel) && await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCategories);

            if (notAvailable && !hasAdminAccess)
            {
                return(InvokeHttp404());
            }

            //'Continue shopping' URL
            await _genericAttributeService.SaveAttributeAsync(await _workContext.GetCurrentCustomerAsync(),
                                                              NopCustomerDefaults.LastContinueShoppingPageAttribute,
                                                              _webHelper.GetThisPageUrl(false),
                                                              (await _storeContext.GetCurrentStoreAsync()).Id);

            //display "edit" (manage) link
            if (await _permissionService.AuthorizeAsync(StandardPermissionProvider.AccessAdminPanel) && await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCategories))
            {
                DisplayEditLink(Url.Action("Edit", "Category", new { id = category.Id, area = AreaNames.Admin }));
            }

            //activity log
            await _customerActivityService.InsertActivityAsync("PublicStore.ViewCategory",
                                                               string.Format(await _localizationService.GetResourceAsync("ActivityLog.PublicStore.ViewCategory"), category.Name), category);

            //model
            var model = await _catalogModelFactory.PrepareCategoryModelAsync(category, command);

            //template
            var templateViewPath = await _catalogModelFactory.PrepareCategoryTemplateViewPathAsync(category.CategoryTemplateId);

            return(View(templateViewPath, model));
        }
コード例 #21
0
        public async Task <IActionResult> Configure()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageWidgets))
            {
                return(AccessDeniedView());
            }

            var model = new ConfigurationModel
            {
                Enabled = _what3WordsSettings.Enabled
            };

            return(View("~/Plugins/Widgets.What3words/Views/Configure.cshtml", model));
        }
コード例 #22
0
        /// <summary>
        /// Prepare the header links model
        /// </summary>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the header links model
        /// </returns>
        public virtual async Task <HeaderLinksModel> PrepareHeaderLinksModelAsync()
        {
            var customer = await _workContext.GetCurrentCustomerAsync();

            var store = await _storeContext.GetCurrentStoreAsync();

            var unreadMessageCount = await GetUnreadPrivateMessagesAsync();

            var unreadMessage = string.Empty;
            var alertMessage  = string.Empty;

            if (unreadMessageCount > 0)
            {
                unreadMessage = string.Format(await _localizationService.GetResourceAsync("PrivateMessages.TotalUnread"), unreadMessageCount);

                //notifications here
                if (_forumSettings.ShowAlertForPM &&
                    !await _genericAttributeService.GetAttributeAsync <bool>(customer, NopCustomerDefaults.NotifiedAboutNewPrivateMessagesAttribute, store.Id))
                {
                    await _genericAttributeService.SaveAttributeAsync(customer, NopCustomerDefaults.NotifiedAboutNewPrivateMessagesAttribute, true, store.Id);

                    alertMessage = string.Format(await _localizationService.GetResourceAsync("PrivateMessages.YouHaveUnreadPM"), unreadMessageCount);
                }
            }

            var model = new HeaderLinksModel
            {
                RegistrationType      = _customerSettings.UserRegistrationType,
                IsAuthenticated       = await _customerService.IsRegisteredAsync(customer),
                CustomerName          = await _customerService.IsRegisteredAsync(customer) ? await _customerService.FormatUsernameAsync(customer) : string.Empty,
                ShoppingCartEnabled   = await _permissionService.AuthorizeAsync(StandardPermissionProvider.EnableShoppingCart),
                WishlistEnabled       = await _permissionService.AuthorizeAsync(StandardPermissionProvider.EnableWishlist),
                AllowPrivateMessages  = await _customerService.IsRegisteredAsync(customer) && _forumSettings.AllowPrivateMessages,
                UnreadPrivateMessages = unreadMessage,
                AlertMessage          = alertMessage,
            };

            //performance optimization (use "HasShoppingCartItems" property)
            if (customer.HasShoppingCartItems)
            {
                model.ShoppingCartItems = (await _shoppingCartService.GetShoppingCartAsync(customer, ShoppingCartType.ShoppingCart, store.Id))
                                          .Sum(item => item.Quantity);

                model.WishlistItems = (await _shoppingCartService.GetShoppingCartAsync(customer, ShoppingCartType.Wishlist, store.Id))
                                      .Sum(item => item.Quantity);
            }

            return(model);
        }
        public async Task <IActionResult> Configure(int discountId, int?discountRequirementId)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageDiscounts))
            {
                return(Content("Access denied"));
            }

            //load the discount
            var discount = await _discountService.GetDiscountByIdAsync(discountId);

            if (discount == null)
            {
                throw new ArgumentException("Discount could not be loaded");
            }

            //check whether the discount requirement exists
            if (discountRequirementId.HasValue && await _discountService.GetDiscountRequirementByIdAsync(discountRequirementId.Value) is null)
            {
                return(Content("Failed to load requirement."));
            }

            //try to get previously saved restricted customer role identifier
            var restrictedRoleId = await _settingService.GetSettingByKeyAsync <int>(string.Format(DiscountRequirementDefaults.SettingsKey, discountRequirementId ?? 0));

            var model = new RequirementModel
            {
                RequirementId  = discountRequirementId ?? 0,
                DiscountId     = discountId,
                CustomerRoleId = restrictedRoleId
            };

            //set available customer roles
            model.AvailableCustomerRoles = (await _customerService.GetAllCustomerRolesAsync(true)).Select(role => new SelectListItem
            {
                Text     = role.Name,
                Value    = role.Id.ToString(),
                Selected = role.Id == restrictedRoleId
            }).ToList();
            model.AvailableCustomerRoles.Insert(0, new SelectListItem
            {
                Text  = await _localizationService.GetResourceAsync("Plugins.DiscountRules.CustomerRoles.Fields.CustomerRole.Select"),
                Value = "0"
            });

            //set the HTML field prefix
            ViewData.TemplateInfo.HtmlFieldPrefix = string.Format(DiscountRequirementDefaults.HtmlFieldPrefix, discountRequirementId ?? 0);

            return(View("~/Plugins/DiscountRules.CustomerRoles/Views/Configure.cshtml", model));
        }
コード例 #24
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public async Task <IActionResult> Configure()
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageExternalAuthenticationMethods))
            {
                return(AccessDeniedView());
            }

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

            return(View("~/Plugins/ExternalAuth.Facebook/Views/Configure.cshtml", model));
        }
コード例 #25
0
        public virtual async Task <IActionResult> Index(int?id, int?pageNumber)
        {
            if (!_customerSettings.AllowViewingProfiles)
            {
                return(RedirectToRoute("Homepage"));
            }

            var customerId = 0;

            if (id.HasValue)
            {
                customerId = id.Value;
            }

            var customer = await _customerService.GetCustomerByIdAsync(customerId);

            if (customer == null || await _customerService.IsGuestAsync(customer))
            {
                return(RedirectToRoute("Homepage"));
            }

            //display "edit" (manage) link
            if (await _permissionService.AuthorizeAsync(StandardPermissionProvider.AccessAdminPanel) && await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCustomers))
            {
                DisplayEditLink(Url.Action("Edit", "Customer", new { id = customer.Id, area = AreaNames.Admin }));
            }

            var model = await _profileModelFactory.PrepareProfileIndexModelAsync(customer, pageNumber);

            return(View(model));
        }
コード例 #26
0
        public virtual async Task <IActionResult> Index()
        {
            //display a warning to a store owner if there are some error
            var hideCard = await _genericAttributeService.GetAttributeAsync <bool>(await _workContext.GetCurrentCustomerAsync(), NopCustomerDefaults.HideConfigurationStepsAttribute);

            var closeCard = await _genericAttributeService.GetAttributeAsync <bool>(await _workContext.GetCurrentCustomerAsync(), NopCustomerDefaults.CloseConfigurationStepsAttribute);

            if ((hideCard || closeCard) && await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance))
            {
                var warnings = await _commonModelFactory.PrepareSystemWarningModelsAsync();

                if (warnings.Any(warning => warning.Level == SystemWarningLevel.Fail ||
                                 warning.Level == SystemWarningLevel.CopyrightRemovalKey ||
                                 warning.Level == SystemWarningLevel.Warning))
                {
                    _notificationService.WarningNotification(
                        string.Format(await _localizationService.GetResourceAsync("Admin.System.Warnings.Errors"),
                                      Url.Action("Warnings", "Common")),
                        //do not encode URLs
                        false);
                }
            }

            //prepare model
            var model = await _homeModelFactory.PrepareDashboardModelAsync(new DashboardModel());

            return(View(model));
        }
コード例 #27
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public async Task <IActionResult> ExportProducts(string selectedIds)
        {
            //ensure that Avalara tax provider is active
            if (!await _taxPluginManager.IsPluginActiveAsync(AvalaraTaxDefaults.SystemName))
            {
                return(RedirectToAction("List", "Product"));
            }

            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageTaxSettings))
            {
                return(AccessDeniedView());
            }

            //export items
            var exportedItems = await _avalaraTaxManager.ExportProductsAsync(selectedIds);

            if (exportedItems.HasValue)
            {
                if (exportedItems > 0)
                {
                    _notificationService.SuccessNotification(string.Format(await _localizationService.GetResourceAsync("Plugins.Tax.Avalara.Items.Export.Success"), exportedItems));
                }
                else
                {
                    _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Plugins.Tax.Avalara.Items.Export.AlreadyExported"));
                }
            }
            else
            {
                _notificationService.ErrorNotification(await _localizationService.GetResourceAsync("Plugins.Tax.Avalara.Items.Export.Error"));
            }

            return(RedirectToAction("List", "Product"));
        }
コード例 #28
0
            /// <summary>
            /// Called early in the filter pipeline to confirm request is authorized
            /// </summary>
            /// <param name="context">Authorization filter context</param>
            /// <returns>A task that on completion indicates the filter has executed</returns>
            private async Task CheckAccessPublicStoreAsync(AuthorizationFilterContext context)
            {
                if (context == null)
                {
                    throw new ArgumentNullException(nameof(context));
                }

                if (!await DataSettingsManager.IsDatabaseInstalledAsync())
                {
                    return;
                }

                //check whether this filter has been overridden for the Action
                var actionFilter = context.ActionDescriptor.FilterDescriptors
                                   .Where(filterDescriptor => filterDescriptor.Scope == FilterScope.Action)
                                   .Select(filterDescriptor => filterDescriptor.Filter)
                                   .OfType <CheckAccessPublicStoreAttribute>()
                                   .FirstOrDefault();

                //ignore filter (the action is available even if navigation is not allowed)
                if (actionFilter?.IgnoreFilter ?? _ignoreFilter)
                {
                    return;
                }

                //check whether current customer has access to a public store
                if (await _permissionService.AuthorizeAsync(StandardPermissionProvider.PublicStoreAllowNavigation))
                {
                    return;
                }

                //customer hasn't access to a public store
                context.Result = new ChallengeResult();
            }
コード例 #29
0
            public async Task OnAuthorizationAsync(AuthorizationFilterContext filterContext)
            {
                if (filterContext == null)
                {
                    throw new ArgumentNullException(nameof(filterContext));
                }

                //check whether this filter has been overridden for the action
                var actionFilter = filterContext.ActionDescriptor.FilterDescriptors
                                   .Where(fd => fd.Scope == FilterScope.Action)
                                   .Select(fd => fd.Filter)
                                   .OfType <AuthorizeUserAttribute>().FirstOrDefault();

                if (actionFilter?.IgnoreFilter ?? _ignoreFilter)
                {
                    return;
                }

                if (!DataSettingsManager.DatabaseIsInstalled)
                {
                    return;
                }

                if (filterContext.Filters.Any(filter => filter is AuthorizeUserFilter))
                {
                    if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.AccessPanel))
                    {
                        filterContext.Result = new ChallengeResult();
                    }
                }
            }
コード例 #30
0
            /// <summary>
            /// Called early in the filter pipeline to confirm request is authorized
            /// </summary>
            /// <param name="context">Authorization filter context</param>
            /// <returns>A task that represents the asynchronous operation</returns>
            private async Task AuthorizeAdminAsync(AuthorizationFilterContext context)
            {
                if (context == null)
                {
                    throw new ArgumentNullException(nameof(context));
                }

                if (!await DataSettingsManager.IsDatabaseInstalledAsync())
                {
                    return;
                }

                //check whether this filter has been overridden for the action
                var actionFilter = context.ActionDescriptor.FilterDescriptors
                                   .Where(filterDescriptor => filterDescriptor.Scope == FilterScope.Action)
                                   .Select(filterDescriptor => filterDescriptor.Filter)
                                   .OfType <AuthorizeAdminAttribute>()
                                   .FirstOrDefault();

                //ignore filter (the action is available even if a customer hasn't access to the admin area)
                if (actionFilter?.IgnoreFilter ?? _ignoreFilter)
                {
                    return;
                }

                //there is AdminAuthorizeFilter, so check access
                if (context.Filters.Any(filter => filter is AuthorizeAdminFilter))
                {
                    //authorize permission of access to the admin area
                    if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.AccessAdminPanel))
                    {
                        context.Result = new ChallengeResult();
                    }
                }
            }