protected void Page_Init(object sender, EventArgs e) { try { this._authority = CommonV5.GetAuthenticationDataAndCulture(HttpContext.Current).Authority; } catch (Exception) { // if this fails FOR WHATEVER REASON then we're not authenticated this._authority = null; FormsAuthentication.SignOut(); Response.Redirect("/", true); } // BEGIN TEST CODE // VatReports.CreateNewReports(); // END TEST CODE if (this._authority.Organization.Identity == 3 && PilotInstallationIds.IsPilot(PilotInstallationIds.PiratePartySE)) { this._authority = null; FormsAuthentication.SignOut(); Response.Redirect("/", true); } }
protected static AuthenticationData GetAuthenticationDataAndCulture() { // This function is called from static page methods in AJAX calls to get // the current set of authentication data. Static page methods cannot access // the instance data of PageV5Base. return(CommonV5.GetAuthenticationDataAndCulture(HttpContext.Current)); }
/// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param> protected override void OnInitComplete(EventArgs e) { base.OnInitComplete(e); string identity = HttpContext.Current.User.Identity.Name; if (!string.IsNullOrEmpty(identity)) { try { CurrentAuthority = CommonV5.GetAuthenticationDataAndCulture(HttpContext.Current).Authority; } catch (Exception) { // if this fails FOR WHATEVER REASON then we're not authenticated this.CurrentAuthority = null; FormsAuthentication.SignOut(); } } else { CurrentAuthority = null; // unauthenticated! } // Regardless of auth data and culture, set Gregorian calendar // (avoids problems with Arabic, etc, calendars and bookkeeping in localization) GregorianCalendar normalizedCalendar = new GregorianCalendar(); normalizedCalendar.CalendarType = GregorianCalendarTypes.USEnglish; // Set the calendar to GregorianCalendar.USEnglish. This sometimes fails on Windows but works // on Mono. If it fails on Windows, no biggie b/c this is supposed to be the default anyway. try { Thread.CurrentThread.CurrentCulture.DateTimeFormat.Calendar = normalizedCalendar; Thread.CurrentThread.CurrentUICulture.DateTimeFormat.Calendar = normalizedCalendar; } catch (Exception) { // meh } }
public static Authority InitAuthority() { try { Authority authority = CommonV5.GetAuthenticationDataAndCulture(HttpContext.Current).Authority; return(authority); } catch (Exception) { // if this fails FOR WHATEVER REASON then we're not authenticated System.Web.Security.FormsAuthentication.SignOut(); if (!HttpContext.Current.Request.Path.ToLowerInvariant().StartsWith("/security/login")) { // If we're not already on the login page, put us on the login page leading to Dashboard HttpContext.Current.Response.Redirect("/"); } return(null); } }
protected void Page_Init(object sender, EventArgs e) { try { this._authority = CommonV5.GetAuthenticationDataAndCulture(HttpContext.Current).Authority; this._authority.Organization.GetMemberCount(); // will throw if Organization can't be looked up } catch (Exception) { // if this fails FOR WHATEVER REASON then we're not authenticated this._authority = null; FormsAuthentication.SignOut(); Response.Redirect("/", true); } // BEGIN TEST CODE // VatReports.CreateNewReports(); // END TEST CODE }
protected static AuthenticationData GetAuthenticationDataAndCulture() { return(CommonV5.GetAuthenticationDataAndCulture(HttpContext.Current)); }