/// <summary> /// Checks to see if user is logged in. /// </summary> private void checkToSeeIfUserIsLoggedIn() { if (IsPublic) { return; // it doesn't matter } if (ConciergeAPI.CurrentUser == null || ConciergeAPI.CurrentEntity == null) // we're not logged in { // is there an auto login set? // the auto login will automatically try to log in the user specified in the config // this is helpful during development, where you don't want to constantly have to // relogin for each compile if (ConfigurationManager.AppSettings["AutoLoginName"] != null) { using (var api = GetConciegeAPIProxy()) ConciergeAPI.SetSession( api.LoginToPortal(ConfigurationManager.AppSettings["AutoLoginName"], ConfigurationManager.AppSettings["AutoLoginPassword"]).ResultValue); MultiStepWizards.ClearAll(); return; } GoTo("/Login.aspx?redirectURL=" + Server.UrlEncode(Request.Url.PathAndQuery)); return; } if (CheckMustChangePassword && ConciergeAPI.CurrentUser.MustChangePassword) { GoTo("~/profile/ChangePassword.aspx"); return; } }
protected void blLoginAs_Click(object sender, BulletedListEventArgs e) { ListItem li = blLoginAs.Items[e.Index]; string loginAsEntityId = li.Value; if (!ConciergeAPI.AccessibleEntities.Exists(x => x.ID.Equals(loginAsEntityId, StringComparison.CurrentCultureIgnoreCase))) { return; } msEntity newEntity = null; using (var api = ConciergeAPIProxyGenerator.GenerateProxy()) { newEntity = api.Get(loginAsEntityId).ResultValue.ConvertTo <msEntity>(); if (newEntity == null) { return; // entity was erased? } var newAccessibleEntities = api.GetAccessibleEntitiesForEntity(newEntity.ID).ResultValue; if (newAccessibleEntities == null) { newAccessibleEntities = new List <LoginResult.AccessibleEntity>(); } //MS-1391 // automatically insert the current entity so there's a login link to switch back if (!newAccessibleEntities.Exists(x => x.ID == ConciergeAPI.CurrentEntity.ID)) { newAccessibleEntities.Insert(0, new LoginResult.AccessibleEntity { ID = ConciergeAPI.CurrentEntity.ID, Name = ConciergeAPI.CurrentEntity.Name, Type = ConciergeAPI.CurrentEntity.ClassType }); } ConciergeAPI.AccessibleEntities = newAccessibleEntities; ConciergeAPI.CurrentEntity = newEntity; // record that this was the last one logged in // let's re-load it from the database var pu = api.Get(ConciergeAPI.CurrentUser.ID).ResultValue.ConvertTo <msPortalUser>(); pu.LastLoggedInAs = newEntity.ID; api.Save(pu); } MultiStepWizards.ClearAll(); Response.Redirect("/default.aspx"); }
public static void ClearSession() { SessionManager.Set<object>("ConciergeAPISessionID", null); SessionManager.Set<object>("APIMessageHeader", null); CurrentUser = null; CurrentEntity = null; CurrentAssociation = null; CurrentTabs = null; AccessibleEntities = null; MultiStepWizards.ClearAll(); setUserIdentificationCookie(); }