示例#1
0
        public ActionResult CreateProviderPost(CreateProviderViewModel viewModel)
        {
            if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage open authentication settings")))
            {
                return(new HttpUnauthorizedResult());
            }

            if (!_providerConfigurationService.VerifyUnicity(viewModel.ProviderName))
            {
                ModelState.AddModelError("ProviderName", T("Provider name already exists").ToString());
            }

            if (!ModelState.IsValid)
            {
                _orchardServices.TransactionManager.Cancel();

                return(View(viewModel));
            }

            _providerConfigurationService.Create(new ProviderConfigurationCreateParams {
                DisplayName        = viewModel.DisplayName,
                ProviderName       = viewModel.ProviderName,
                ProviderIdentifier = viewModel.ProviderIdentifier,
                ProviderIdKey      = viewModel.ProviderIdKey,
                ProviderSecret     = viewModel.ProviderSecret,
            });
            _orchardServices.Notifier.Information(T("Your configuration has been saved."));

            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult Edit(CreateProviderViewModel viewModel)
        {
            if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage open authentication settings")))
            {
                return(new HttpUnauthorizedResult());
            }

            if (!_providerConfigurationService.VerifyUnicity(viewModel.ProviderName, viewModel.Id))
            {
                ModelState.AddModelError("ProviderName", T("Provider name already exists").ToString());

                viewModel.ProviderNameList = getAllProviderName(viewModel.ProviderName);
                return(View(viewModel));
            }
            else
            {
                _providerConfigurationService.Edit(viewModel);
                _providerConfigurationService.SaveAttributes(viewModel.Id, viewModel.Attributes);
                return(RedirectToAction("Index"));
            }
        }