private bool RestoreExtensionFolder(string extensionFolder, string extensionId) { var virtualSource = _virtualPathProvider.Combine("~", extensionFolder, extensionId); var source = new DirectoryInfo(_virtualPathProvider.MapPath(virtualSource)); if (source.Exists) { var tempPath = _virtualPathProvider.Combine("~/App_Data", "_Backup", extensionFolder, extensionId); string localTempPath = null; for (int i = 0; i < 1000; i++) { localTempPath = _virtualPathProvider.MapPath(tempPath) + (i == 0 ? "" : "." + i.ToString()); if (!System.IO.Directory.Exists(localTempPath)) { System.IO.Directory.CreateDirectory(localTempPath); break; } localTempPath = null; } if (localTempPath == null) { throw new SmartException(T("Admin.Packaging.TooManyBackups", tempPath)); } var backupFolder = new DirectoryInfo(localTempPath); _folderUpdater.Restore(backupFolder, source); _notifier.Information(T("Admin.Packaging.RestoreSuccess", virtualSource)); return(true); } return(false); }
private bool RestoreExtensionFolder(string extensionFolder, string extensionId) { var source = new DirectoryInfo(_virtualPathProvider.MapPath(_virtualPathProvider.Combine("~", extensionFolder, extensionId))); if (source.Exists) { var tempPath = _virtualPathProvider.Combine("~", extensionFolder, "_Backup", extensionId); string localTempPath = null; for (int i = 0; i < 1000; i++) { localTempPath = _virtualPathProvider.MapPath(tempPath) + (i == 0 ? "" : "." + i.ToString()); if (!Directory.Exists(localTempPath)) { Directory.CreateDirectory(localTempPath); break; } localTempPath = null; } if (localTempPath == null) { throw new OrchardException(T("Backup folder {0} has too many backups subfolder (limit is 1,000)", tempPath)); } var backupFolder = new DirectoryInfo(localTempPath); _folderUpdater.Restore(backupFolder, source); _notifier.Information(T("Successfully restored local package to local folder \"{0}\"", source)); return(true); } return(false); }
private ActionResult CreateHierarchyPost(string typeName, string returnUrl, Action <ContentItem> conditionallyPublish) { return(ExecuteHierarchyPost(new TerritoriesAdminHierarchyExecutionContext { HierarchyItem = _contentManager.New(typeName), Message = TerritoriesUtilities.Creation401HierarchyMessage, AdditionalPermissions = new Permission[] { Orchard.Core.Contents.Permissions.EditContent }, ExecutionAction = item => { _contentManager.Create(item, VersionOptions.Draft); var model = _contentManager.UpdateEditor(item, this); if (!ModelState.IsValid) { _transactionManager.Cancel(); return View(model); } conditionallyPublish(item); _notifier.Information(string.IsNullOrWhiteSpace(item.TypeDefinition.DisplayName) ? T("Your content has been created.") : T("Your {0} has been created.", item.TypeDefinition.DisplayName)); return this.RedirectLocal(returnUrl, () => RedirectToAction("EditHierarchy", new RouteValueDictionary { { "Id", item.Id } })); } })); }
public async Task <IActionResult> NextContentItemInList(string currentContentItemId) { var allFlattendedNodes = await AllFlattendedNodes(currentContentItemId); //https://stackoverflow.com/questions/2680228/linq-next-item-in-list var index = allFlattendedNodes.FindIndex((x => x.Id == currentContentItemId)); try { var nextContentItem = allFlattendedNodes[index + 1]; //next item in list by index if (nextContentItem == null) { return(NotFound()); } var displayRouteValues = (await _contentManager.PopulateAspectAsync <ContentItemMetadata>(nextContentItem.ContentItem)).DisplayRouteValues; return(RedirectToRoute(displayRouteValues)); } catch (ArgumentOutOfRangeException) { //this means we are at end of list . notify user and stay on current item //throw new ArgumentOutOfRangeException("index", ex); var currentContentItem = await _contentManager.GetAsync(currentContentItemId, VersionOptions.Published); var currentContentdisplayRouteValues = (await _contentManager.PopulateAspectAsync <ContentItemMetadata>(currentContentItem)) .DisplayRouteValues; _notifier.Information(H["Already at the last list item."]); return(RedirectToRoute(currentContentdisplayRouteValues)); } }
public ActionResult Create(string id, ProfileViewModel viewModel, FormCollection formCollection) { viewModel.Theme = _themeSettingsService.GetTheme(id); if (!ModelState.IsValid) { var settingsManifest = _themeSettingsService.GetSettingsManifest(id); var form = _settingsFormBuilder.BuildForm(settingsManifest); _settingsFormBuilder.BindForm(form, formCollection); viewModel.SettingsForm = _settingsFormBuilder.BindForm(form, formCollection); return(View(viewModel)); } var profile = new ThemeProfile { Name = viewModel.Name.TrimSafe(), Description = viewModel.Description.TrimSafe(), Theme = id, Settings = ParseThemeSettings(formCollection), IsCurrent = viewModel.IsCurrent }; _themeSettingsService.SaveProfile(profile); _notifier.Information(T("The profile {0} for the {1} theme was succesfully created.", viewModel.Name, viewModel.Theme.Name)); return(RedirectToAction("Edit", new { id = profile.Id })); }
public async Task <ActionResult> CreatePartPOST(CreatePartViewModel viewModel) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.EditContentTypes)) { return(Unauthorized()); } if (_contentDefinitionManager.GetPartDefinition(viewModel.Name) != null) { ModelState.AddModelError("Name", S["Cannot add part named '{0}'. It already exists.", viewModel.Name]); } if (!ModelState.IsValid) { return(View(viewModel)); } var partViewModel = _contentDefinitionService.AddPart(viewModel); if (partViewModel == null) { _notifier.Information(T["The content part could not be created."]); return(View(viewModel)); } _notifier.Success(T["The \"{0}\" content part has been created.", partViewModel.Name]); return(RedirectToAction("EditPart", new { id = partViewModel.Name })); }
public ActionResult Edit(int id, ElementDataViewModel model) { var blueprint = _elementBlueprintService.GetBlueprint(id); var describeContext = DescribeElementsContext.Empty; var descriptor = _elementManager.GetElementDescriptorByTypeName(describeContext, blueprint.BaseElementTypeName); var data = ElementDataHelper.Deserialize(model.ElementData).Combine(Request.Form.ToDictionary()); var element = _elementManager.ActivateElement(descriptor, e => e.Data = data); var context = CreateEditorContext(element, elementData: data); var editorResult = _elementManager.UpdateEditor(context); var viewModel = new EditElementBlueprintViewModel { EditorResult = editorResult, TypeName = model.TypeName, DisplayText = descriptor.DisplayText, Description = descriptor.Description, ElementData = element.Data.Serialize(), Tabs = editorResult.CollectTabs().ToArray(), BaseElement = element }; if (!ModelState.IsValid) { _transactionManager.Cancel(); return(View(viewModel)); } blueprint.BaseElementState = data.Serialize(); _signals.Trigger(Signals.ElementDescriptors); _notifier.Information(T("That blueprint has been saved.")); return(RedirectToAction("Index")); }
public ActionResult ExternalLogOn(string returnUrl) { AuthenticationResult result = _orchardOpenAuthWebSecurity.VerifyAuthentication(Url.OpenAuthLogOn(returnUrl)); if (!result.IsSuccessful) { _notifier.Error(T("Your authentication request failed.")); return(new RedirectResult(Url.LogOn(returnUrl))); } if (_orchardOpenAuthWebSecurity.Login(result.Provider, result.ProviderUserId)) { _notifier.Information(T("You have been logged using your {0} account.", result.Provider)); return(this.RedirectLocal(returnUrl)); } var authenticatedUser = _authenticationService.GetAuthenticatedUser(); if (authenticatedUser != null) { // If the current user is logged in add the new account _orchardOpenAuthWebSecurity.CreateOrUpdateAccount(result.Provider, result.ProviderUserId, authenticatedUser); _notifier.Information(T("Your {0} account has been attached to your local account.", result.Provider)); return(this.RedirectLocal(returnUrl)); } if (_openAuthMembershipServices.CanRegister()) { var newUser = _openAuthMembershipServices.CreateUser(new OpenAuthCreateUserParams(result.UserName, result.Provider, result.ProviderUserId, result.ExtraData)); _notifier.Information( T("You have been logged in using your {0} account. We have created a local account for you with the name '{1}'", result.Provider, newUser.UserName)); _orchardOpenAuthWebSecurity.CreateOrUpdateAccount(result.Provider, result.ProviderUserId, newUser); _authenticationService.SignIn(newUser, false); return(this.RedirectLocal(returnUrl)); } string loginData = _orchardOpenAuthWebSecurity.SerializeProviderUserId(result.Provider, result.ProviderUserId); ViewBag.ProviderDisplayName = _orchardOpenAuthWebSecurity.GetOAuthClientData(result.Provider).DisplayName; ViewBag.ReturnUrl = returnUrl; return(new RedirectResult(Url.LogOn(returnUrl, result.UserName, HttpUtility.UrlEncode(loginData)))); }
public void EnableFeatures(IEnumerable <string> featureIds, bool force) { foreach (var featureId in featureManager.EnableFeatures(featureIds, force)) { var featureName = featureManager.GetAvailableFeatures().First(f => f.Id.Equals(featureId, StringComparison.OrdinalIgnoreCase)).Name; notifier.Information(T("{0} was enabled", featureName)); } }
public ActionResult Index() { _notifier.Information(T("Test information")); _notifier.Information(T("Test information 2")); _notifier.Error(T("Test error")); _notifier.Warning(T("Test warning")); _notifier.Error(T("Test error")); _notifier.Information(T("Test information")); return(Redirect("~/")); }
public ActionResult EvictByKey(string cacheKey, string returnUrl) { if (!mAuthorizer.Authorize(ItemLevelCachePermissions.EvictItemLevelCacheItems, T("You do not have permission to evict item-level cache items."))) { return(new HttpUnauthorizedResult()); } mCacheStorageProvider.Remove(cacheKey); mNotifier.Information(T("The cache item was removed.")); return(this.RedirectLocal(returnUrl)); }
public ActionResult Search(PagerParameters pagerParameters, string q = "") { q = q.Trim(); if (string.IsNullOrEmpty(q)) { return(Redirect(Request.UrlReferrer != null ? Request.UrlReferrer.ToString() : Url.Content("~/"))); } PagedList <ISearchHit> searchHits; try { searchHits = searchService.Query(q, 0, 20, searchSettings.SearchedFields, WorkContext.CurrentCulture, searchHit => searchHit); } catch (Exception exception) { Logger.Error(T("Invalid search query: {0}", exception.Message).Text); notifier.Error(T("Invalid search query: {0}", exception.Message)); searchHits = new PagedList <ISearchHit>(new ISearchHit[] { }); } var sb = new StringBuilder(); if (searchHits.ItemCount == 0) { notifier.Information(T("Your search - {0} - did not match any documents.", new HtmlString("<strong>" + q + "</strong>"))); } else { notifier.Information(T("Your search - {0} - resulted in {1} documents.", new HtmlString("<strong>" + q + "</strong>"), searchHits.ItemCount)); sb.Append("<ul class=\"thumbnails search-results\">"); foreach (var searchHit in searchHits) { sb.Append("<li>"); sb.AppendFormat("<a href=\"{1}\">{0}</a>", searchHit.GetString("title"), searchHit.GetString("url")); sb.AppendFormat("<div class=\"description\">{0}</div>", searchHit.GetString("description") ?? searchHit.GetString("body")); sb.Append("</li>"); } sb.Append("</ul>"); } var result = new ControlContentResult(sb.ToString()) { Title = T("Search") }; return(result); }
public async Task <ActionResult> CreatePartPOST(CreatePartViewModel viewModel) { if (!await _authorizationService.AuthorizeAsync(User, Permissions.EditContentTypes)) { return(Forbid()); } viewModel.Name = viewModel.Name ?? String.Empty; if (String.IsNullOrWhiteSpace(viewModel.Name)) { ModelState.AddModelError("Name", S["The Technical Name can't be empty."]); } if (_contentDefinitionService.LoadParts(false).Any(p => String.Equals(p.Name.Trim(), viewModel.Name.Trim(), StringComparison.OrdinalIgnoreCase))) { ModelState.AddModelError("Name", S["A part with the same Technical Name already exists."]); } if (!String.IsNullOrWhiteSpace(viewModel.Name) && !viewModel.Name[0].IsLetter()) { ModelState.AddModelError("Name", S["The Technical Name must start with a letter."]); } if (!String.Equals(viewModel.Name, viewModel.Name.ToSafeName(), StringComparison.OrdinalIgnoreCase)) { ModelState.AddModelError("Name", S["The Technical Name contains invalid characters."]); } if (viewModel.Name.IsReservedContentName()) { ModelState.AddModelError("Name", S["The Technical Name is reserved for internal use."]); } if (!ModelState.IsValid) { return(View(viewModel)); } var partViewModel = _contentDefinitionService.AddPart(viewModel); if (partViewModel == null) { _notifier.Information(H["The content part could not be created."]); return(View(viewModel)); } _notifier.Success(H["The \"{0}\" content part has been created.", partViewModel.Name]); return(RedirectToAction(nameof(EditPart), new { id = partViewModel.Name })); }
private bool TryUpdateSubscription(MailchimpSubscriptionPart part) { // When a User is Created a Published is improperly called to early and the part is not Updated // So I skip this step if (part.Subscription.Audience == null) { return(false); } if (part.As <UserPart>() != null && part.As <UserPart>().EmailStatus != UserStatus.Approved) { // A registered user with an EmailStatus not Approved should not Update Mailchimp member return(false); } if (!part.IsPublished()) { return(false); } // check if subscriptions is different from orchard to mailchimp // if changed it fires an update over Mailchimp servers if (part.Subscription.Subscribed != _apiService.IsUserRegistered(part) || part.As <UserPart>() == null) { var settings = part.Settings.GetModel <MailchimpSubscriptionPartSettings>(); if (!_apiService.TryUpdateSubscription(part)) { if (settings.NotifySubscriptionResult || AdminFilter.IsApplied(_workContext.GetContext().HttpContext.Request.RequestContext)) { _notifier.Error(T("Oops! We have experienced a problem during your email subscription. Please, retry later.")); } return(false); } else { if (settings.NotifySubscriptionResult || AdminFilter.IsApplied(_workContext.GetContext().HttpContext.Request.RequestContext)) { if (part.Subscription.Subscribed) { _notifier.Information(T("Nice to meet you! Your subscription has been accepted.")); } else { _notifier.Information(T("You have been unsubscribed.")); } } return(true); } } else { return(false); } }
public ActionResult CheckTFALogin(string userNameOrEmail, string password, string returnUrl, bool rememberMe = false) { _userEventHandler.LoggingIn(userNameOrEmail, password); var user = ValidateLogOn(userNameOrEmail, password); if (!ModelState.IsValid) { //var errors = ModelState.Keys.SelectMany(k => ModelState[k].Errors).Select(m => m.ErrorMessage).ToArray(); var errorList = (from item in ModelState where item.Value.Errors.Any() select item.Value.Errors[0].ErrorMessage).ToList(); return(Json(new { error = true, errors = errorList })); } //Handle TFA var userTFA = user.As <TwoFactorAuthenticationPart>(); var settings = _orchardServices.WorkContext.CurrentSite.As <TwoFactorAuthenticationSettingsPart>(); if (!userTFA.CanLoginWithoutTFA && (settings.RequireTFA || userTFA.EnableTFA)) { Session["user"] = user; Session["rememberMe"] = rememberMe; Session["displayTFAChallenge"] = true; return(Json(new { displayTFAChallenge = "True", error = false })); } //Messages if (userTFA.CanLoginWithoutTFA && (settings.RequireTFA || userTFA.EnableTFA)) { _notifier.Information(T("An admin has allowed you to login without Two-Factor Authentication.")); if (settings.RequireTFA) { _notifier.Information(T("Two-Factor Authentication is required. Please ensure TFA has been set up prior to logging out.")); } else { _notifier.Information(T("Please disable or ensure correct setup of TFA prior to logging out.")); } //Some way of not hardcoding this??? returnUrl = "/Admin/MyProfile"; } _authenticationService.SignIn(user, rememberMe); _userEventHandler.LoggedIn(user); return(Json(new { displayTFAChallenge = "False", returnUrl = returnUrl, error = false })); }
public void Created(UserContext context) { var role = _roleService.GetRoleByName("Harvester"); if (role == null) { _notifier.Warning(T("No role found with the name <strong>Harvester</strong>")); return; } _userRolesRepository.Create(new UserRolesPartRecord { Role = role, UserId = context.User.Id }); _notifier.Information(T("Thanks for registering! You have been added to the {0} role.", role.Name)); }
protected override DriverResult Editor(ShareBarSettingsPart part, IUpdateModel updater, dynamic shapeHelper) { if (!_authorizationService.TryCheckAccess(Permissions.EditSettings, _authenticationService.GetAuthenticatedUser(), part)) { return(null); } // Verifico di provenire dalla pagina dei settings var request = _services.WorkContext.HttpContext.Request.RequestContext.RouteData; var fullAreaControllerAction = string.Format("{0}/{1}/{2}/{3}", request.Values["area"].ToString(), request.Values["controller"], request.Values["action"], request.Values["groupInfoId"]); if (!fullAreaControllerAction.Equals("settings/admin/index/", System.StringComparison.InvariantCultureIgnoreCase)) { return(null); } if (updater.TryUpdateModel(part, Prefix, null, null)) { _notifier.Information(T("Content sharing settings updated successfully")); } else { _notifier.Error(T("Error during content sharing settings update!")); } return(Editor(part, shapeHelper)); }
public ActionResult EditUserPasswordPost(ChangePasswordViewModel model) { if (!Services.Authorizer.Authorize(Permissions.ChangePassword, T("Not authorized to manage users"))) { return(new HttpUnauthorizedResult()); } var user = Services.ContentManager.Get <UserPart>(model.UserId); if (!this.ModelState.IsValid) { var viewModel = new ChangePasswordViewModel() { UserPart = user, UserId = user.Id }; return(View(viewModel)); } _membershipService.SetPassword(user, model.Password); notifier.Information(T("User password for " + user.UserName + " changed!")); return(RedirectToAction("Index")); }
public ActionResult IndexPost() { if (!_authorizer.Authorize(MultiStepAuthenticationPermissions.ConfigureAuthentication, null, T("Not authorized to manage settings for multi-step authentication"))) { return(new HttpUnauthorizedResult()); } var site = _siteService.GetSiteSettings(); dynamic model = _contentManager.UpdateEditor(site, this, groupInfoId); if (model == null) { _transactionManager.Cancel(); return(HttpNotFound()); } if (!ModelState.IsValid) { _transactionManager.Cancel(); return(View(model)); } _notifier.Information(T("Nonce login settings updated")); return(RedirectToAction("Index")); }
public ActionResult IndexPost() { if (!_authorizer.Authorize(CommercePermissions.ManageCommerce, null, T("Not authorized to manage address configuration settings"))) { return(new HttpUnauthorizedResult()); } var site = _siteService.GetSiteSettings(); var model = _contentManager.UpdateEditor(site, this, groupInfoId); if (model == null) { _transactionManager.Cancel(); return(HttpNotFound()); } if (!ModelState.IsValid) { _transactionManager.Cancel(); return(View(model)); } _notifier.Information(T("Address configuration settings updated")); return(RedirectToAction("Index")); }
public ActionResult NotifyMe() { // Note that CurrentUser is an IUser instance which is an IContent derivation. Thus users are content items too! var currentUser = _wca.GetContext().CurrentUser; var currentUserName = currentUser == null ? "<subject name here>" : currentUser.UserName; // The below is the same as _wca.GetContext().HttpContext.Request.Url.ToString() // Note that if you use the WorkContext multiple times in the same method of course you can save it to a variable instead of // calling GetContext() each time. var currentUrl = _hca.Current().Request.Url.ToString(); // The notifier requires a localized string. This means if we'd have a corresponding entry for this string in a .po file // then it would appear in e.g. Hungarian if we would have the locale set to hu-HU. // See: http://docs.orchardproject.net/Documentation/Creating-global-ready-applications // Also, this is the way to have localized strings with dynamically injected content. _notifier.Information(T("Please continue testing. -- Subject name: {0}; Subject location: {1}", currentUserName, currentUrl)); // This will get into the logs, really. Check the latest log in App_Data/Logs! Logger.Error("Test subject notified."); // We redirect to the first controller here but the notification will still be displayed. This is because notifications // are meant to provide a way to interact with the user even after a redirect. Of course after they're shown once // notifications will be dismissed. return(RedirectToAction("Index", "YourFirstOrchard")); // NEXT STATION: Models/PersonRecord }
public ActionResult RepopulateFeedSyncProfileItems(int id, string returnUrl) { var feedSyncProfile = _contentManager.Get(id); if (!_authorizer.Authorize(Permissions.EditContent, feedSyncProfile)) { return(new HttpUnauthorizedResult(T("You are not allowed to repopulate feed sync profiles.").Text)); } if (feedSyncProfile == null || feedSyncProfile.ContentType != ContentTypes.FeedSyncProfile) { _notifier.Error(T("Scheduling the repopulation failed.")); } else { var feedSyncProfilePart = feedSyncProfile.As <FeedSyncProfilePart>(); feedSyncProfilePart.SuccesfulInit = false; feedSyncProfilePart.LatestCreatedItemModificationDate = default(DateTime); _notifier.Information(T("Repopulation was successfully scheduled.")); } if (string.IsNullOrEmpty(returnUrl)) { returnUrl = "~/"; } return(this.RedirectLocal(returnUrl)); }
public async Task <IActionResult> Purge() { if (!await _authorizationService.AuthorizeAsync(User, MediaCachePermissions.ManageAssetCache)) { return(Forbid()); } if (_mediaFileStoreCache == null) { _notifier.Error(H["The asset cache feature is enabled, but a remote media store feature is not enabled, or not configured with appsettings.json."]); RedirectToAction(nameof(Index)); } var hasErrors = await _mediaFileStoreCache.PurgeAsync(); if (hasErrors) { _notifier.Error(H["Asset cache purged, with errors."]); } else { _notifier.Information(H["Asset cache purged."]); } return(RedirectToAction(nameof(Index))); }
public ActionResult Restore(int id, string returnUrl) { var contentItem = _contentManager.Get(id, VersionOptions.AllVersions); if (!_authorizer.Authorize(Core.Contents.Permissions.PublishContent, contentItem)) { return(new HttpUnauthorizedResult()); } var restoredContentItem = _recycleBin.Restore(contentItem); var restoredContentItemTitle = _contentManager.GetItemMetadata(restoredContentItem).DisplayText; _notifier.Information(T(""{0}" has been restored.", restoredContentItemTitle)); return(this.RedirectReturn(returnUrl, () => Url.Action("Index", "RecycleBin"))); }
public ActionResult Delete(int id, string returnUrl = "") { var user = _workContextAccessor.GetContext().CurrentUser; if (user == null) { // we should never be here, because the AuthorizeAttribute should // take care of anonymous users. return(new HttpUnauthorizedResult(T("Sign In to manage your saved addresses.").Text)); } _nwazetCommunicationService.DeleteAddress(id, user); _notifier.Information(T("That address has been removed.")); return(this.RedirectLocal(returnUrl, () => RedirectToAction("MyAddresses"))); }
public async Task <IActionResult> Clone(string contentItemId, string returnUrl) { var contentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.Latest); if (contentItem == null) { return(NotFound()); } if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.CloneContent, contentItem)) { return(Forbid()); } try { await _contentManager.CloneAsync(contentItem); } catch (InvalidOperationException) { _notifier.Warning(H["Could not clone the content item."]); return(Url.IsLocalUrl(returnUrl) ? (IActionResult)LocalRedirect(returnUrl) : RedirectToAction("List")); } _notifier.Information(H["Successfully cloned. The clone was saved as a draft."]); return(Url.IsLocalUrl(returnUrl) ? (IActionResult)LocalRedirect(returnUrl) : RedirectToAction("List")); }
public void Enabled(global::Orchard.Environment.Extensions.Models.Feature feature) { var settings = _services.WorkContext.CurrentSite.As <ProtectionSettingsPart>(); if (String.IsNullOrWhiteSpace(settings.ProtectedEntries)) { var defaultProtectedEntries = new string[] { "Laser.Orchard.WebServices.Json.GetByAlias", "Laser.Orchard.WebServices.Signal.Trigger", "Laser.Orchard.Braintree.Paypal.GetClientToken", "Laser.Orchard.Braintree.Paypal.Pay", "Laser.Orchard.WebServices.WebApi.Display", "Laser.Orchard.WebServices.WebApi.Terms" }; settings.ProtectedEntries = String.Join(",", defaultProtectedEntries); } if (!settings.ExternalApplicationList.ExternalApplications.Any()) { var appList = new ExternalApplicationList(); var apps = new List <ExternalApplication>(); var api = ""; var name = ""; apps.Add(new ExternalApplication { Name = name = String.Format("{0}App", _settings.Name), ApiKey = api = new WebApiUtils().RandomString(22), EnableTimeStampVerification = true, Validity = 10 }); appList.ExternalApplications = apps; settings.ExternalApplicationList = appList; _notifier.Information(T("A default app named \"{0}\" has been created. Its Api Key is {1}.", name, api)); } }
private void MergeUserToClosestMergeable(IUser user) { var userPart = user.ContentItem.As <UserPart>(); if (userPart.LastLoginUtc != null) { return; } if (userPart.EmailStatus == UserStatus.Pending || userPart.RegistrationStatus == UserStatus.Pending) { return; } var closestUser = _orchardOpenAuthWebSecurity.GetClosestMergeableKnownUser(userPart); if (closestUser != null && closestUser.UserName != user.UserName) { closestUser.ContentItem.As <UserPart>().Password = userPart.Password; closestUser.ContentItem.As <UserPart>().PasswordFormat = userPart.PasswordFormat; closestUser.ContentItem.As <UserPart>().PasswordSalt = userPart.PasswordSalt; closestUser.ContentItem.As <UserPart>().UserName = userPart.UserName; closestUser.ContentItem.As <UserPart>().NormalizedUserName = userPart.NormalizedUserName; closestUser.ContentItem.As <UserPart>().HashAlgorithm = userPart.HashAlgorithm; _contentManager.Destroy(userPart.ContentItem); _notifier.Information(T("Your account has been merged with your previous account.")); } }
public ActionResult Take() { _snapshotService.TakeSnaphot(); _notifier.Information(T("A snapshot of this site's current configuration has been taken and added to the collection.")); return(RedirectToAction("Index")); }
public ActionResult Create(int id, string returnUrl) { var model = Services.ContentManager.Create <ContactPart>("Contact"); var form = Services.ContentManager.Get(id); if (InvalidForm(form)) { _notifier.Error(T("Form submission was not from a valid source")); return(this.RedirectLocal(returnUrl, "~/")); } var contactForm = form.Parts.FirstOrDefault(p => p is ContactFormPart); TryUpdateModel(model, new[] { "Company", "CurrentWebsite", "Email", "Message", "Name", "Phone", "Topic" }); if (ModelState.IsValid) { var contact = _contactService.MakeContact(model.Record); _messenger.Send(contactForm.ContentItem.Record, MessageTypes.ContactRequest, "email", mapProperties(contact)); _notifier.Information(T("Thanks for your inquiry, someone will respond to you shortly.")); // TODO: great place for a setting } else { notifyUserOfErrors(ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage)); populateTempDataWithViewModelValues(model); } return(this.RedirectLocal(returnUrl, "~/")); }