// handles the button click protected void doSignIn_Click(object sender, System.EventArgs e) { if (SiteConfig.EncryptLoginPassword) { string viewStateChallenge = ViewState["challenge"] as string; if (viewStateChallenge == null) { throw new ArgumentException("Password Challenge was null in ViewState!"); } UserToken token = SiteSecurity.Login(username.Text, challenge.Value, viewStateChallenge.ToString()); if (token != null) { SetAuthCookie(token.Name, username.Text); Response.Redirect(SiteUtilities.GetAdminPageUrl(), true); } else { challenge.Value = Session.SessionID.ToString(); ViewState["challenge"] = challenge.Value; } } else { UserToken token = SiteSecurity.Login(username.Text, password.Text); if (token != null) { SetAuthCookie(token.Name, username.Text); Response.Redirect(SiteUtilities.GetAdminPageUrl(), true); } } }
override protected void OnInit(EventArgs e) { if (User.Identity.IsAuthenticated) { Response.Redirect(SiteUtilities.GetAdminPageUrl(), true); } InitializeComponent(); base.OnInit(e); }
/// <summary> /// Fired upon login. /// Note, that straight after login, forms auth will redirect the user to their original page. So this page may never be rendererd. /// </summary> protected void OpenIdLogin1_LoggedIn(object sender, OpenIdEventArgs e) { // only allow the openid validation when it's enabled in the siteconfig if (SiteConfig.AllowOpenIdAdmin) { e.Cancel = true; //Need to cancel or the control will log us in for free. Eek! UserToken token = SiteSecurity.Login(e.Response); if (token != null) { SetAuthCookie(token.Name, token.Name); Response.Redirect(SiteUtilities.GetAdminPageUrl(), true); } } }
public static string GetAdminPageUrl(SiteConfig siteConfig) { return(SiteUtilities.GetAdminPageUrl(siteConfig)); }
public static string GetAdminPageUrl() { return(SiteUtilities.GetAdminPageUrl()); }
protected void save_Click(object sender, EventArgs e) { SharedBasePage requestPage = this.Page as SharedBasePage; if (SiteSecurity.IsValidContributor()) { //Catch empty posts! if (!editControl.HasText()) { return; } CrosspostInfoCollection crosspostList = new CrosspostInfoCollection(); Entry entry; if (CurrentEntry == null) { entry = new Entry(); entry.Initialize(); } else { entry = CurrentEntry; } //Try a culture specific parse... // TODO: Come up with a shiny javascript datetime picker if (textDate.SelectedDateFormatted.Length > 0) { try { DateTime createdLocalTime = new DateTime(textDate.SelectedDate.Year, textDate.SelectedDate.Month, textDate.SelectedDate.Day, entry.CreatedLocalTime.Hour, entry.CreatedLocalTime.Minute, entry.CreatedLocalTime.Second, entry.CreatedLocalTime.Millisecond); entry.CreatedLocalTime = createdLocalTime; } catch (FormatException fex) { Trace.Write("Bad DateTime string creating new Entry: " + fex.ToString()); } } // see if we need to delete any old Enclosures if (entry.Enclosure != null) { if (this.enclosureUpload.Visible == true && this.buttonRemove.Visible == false) { DeleteEnclosures(); } } // upload the attachment if (enclosureUpload.Value != null && enclosureUpload.Value != String.Empty) { try { long numBytes; string type; string baseFileName; string fileUrl = HandleUpload(enclosureUpload, entry.EntryId, out type, out numBytes, out baseFileName); entry.Attachments.Add(new Attachment(baseFileName, type, numBytes, AttachmentType.Enclosure)); } catch (Exception exc) { ErrorTrace.Trace(TraceLevel.Error, exc); } } entry.Language = listLanguages.SelectedValue == "" ? null : listLanguages.SelectedValue; entry.Title = entryTitle.Text; entry.Description = entryAbstract.Text; entry.Author = requestPage.User.Identity.Name; entry.AllowComments = checkBoxAllowComments.Checked; entry.IsPublic = checkBoxPublish.Checked; entry.Syndicated = checkBoxSyndicated.Checked; // GeoRSS. if (siteConfig.EnableGeoRss) { double latitude, longitude; if (double.TryParse(txtLat.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out latitude)) { entry.Latitude = latitude; } else { entry.Latitude = null; } if (double.TryParse(txtLong.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out longitude)) { entry.Longitude = longitude; } else { entry.Longitude = null; } } if (isDHTMLEdit) { entry.Content = editControl.Text; } // handle categories string categories = ""; StringBuilder sb = new StringBuilder(); bool needSemi = false; foreach (ListItem listItem in categoryList.Items) { if (listItem.Selected) { if (needSemi) { sb.Append(";"); } sb.Append(listItem.Text); needSemi = true; } } categories = sb.ToString(); entry.Categories = categories; // handle crosspostSiteInfo CrosspostInfoCollection crosspostSiteInfo = new CrosspostInfoCollection(); // we need to reload the crosspostinfo as it contains sensitive data like password foreach (CrosspostSite site in requestPage.SiteConfig.CrosspostSites) { CrosspostInfo ci = new CrosspostInfo(site); ci.TrackingUrlBase = SiteUtilities.GetCrosspostTrackingUrlBase(requestPage.SiteConfig); crosspostSiteInfo.Add(ci); } // merge the crosspost config with the crosspost data foreach (CrosspostInfo cpi in crosspostSiteInfo) { foreach (Crosspost cp in entry.Crossposts) { if (cp.ProfileName == cpi.Site.ProfileName) { cpi.IsAlreadyPosted = true; cpi.TargetEntryId = cp.TargetEntryId; cpi.Categories = cp.Categories; break; } } } foreach (DataGridItem item in gridCrossposts.Items) { CheckBox checkSite = item.FindControl("checkSite") as CheckBox; if (checkSite.Checked) { TextBox textSiteCategory = item.FindControl("textSiteCategory") as TextBox; foreach (CrosspostInfo cpi in crosspostSiteInfo) { if (cpi.Site.ProfileName == checkSite.Text) { cpi.Categories = textSiteCategory.Text; crosspostList.Add(cpi); break; } } } } try { // prevent SaveEntry from happenning twice if (crosspostList.Count == 0) { crosspostList = null; } if (CurrentEntry == null) // new entry { SiteUtilities.SaveEntry(entry, this.textTrackback.Text, crosspostList, requestPage.SiteConfig, requestPage.LoggingService, requestPage.DataService); } else // existing entry { SiteUtilities.UpdateEntry(entry, this.textTrackback.Text, crosspostList, requestPage.SiteConfig, requestPage.LoggingService, requestPage.DataService); } } catch (Exception ex) { //SDH: Changed to ex.ToString as the InnerException is often null, which causes another error in this catch! StackTrace st = new StackTrace(); requestPage.LoggingService.AddEvent( new EventDataItem(EventCodes.Error, ex.ToString() + Environment.NewLine + st.ToString(), SiteUtilities.GetPermaLinkUrl(entry))); // if we created a new entry, and there was an error, delete the enclosure folder DeleteEnclosures(); requestPage.Redirect("FormatPage.aspx?path=SiteConfig/pageerror.format.html"); } entryTitle.Text = ""; entryAbstract.Text = ""; categoryList.Items.Clear(); if (Session["newtelligence.DasBlog.Web.EditEntryBox.OriginalReferrer"] != null) { Uri originalReferrer = Session["newtelligence.DasBlog.Web.EditEntryBox.OriginalReferrer"] as Uri; Session.Remove("newtelligence.DasBlog.Web.EditEntryBox.OriginalReferrer"); Redirect(originalReferrer.AbsoluteUri); } else { Redirect(SiteUtilities.GetAdminPageUrl(requestPage.SiteConfig)); } } }