protected void lnkloginStatus_Click(object sender, EventArgs e) { SageFrameConfig SageConfig = new SageFrameConfig(); SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension); bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingsByKey(SageFrameSettingKeys.EnableSessionTracker)); if (EnableSessionTracker) { SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog(); sLog.SessionLogEnd(GetPortalID); } SecurityPolicy objSecurity = new SecurityPolicy(); HttpCookie authenticateCookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID)); authenticateCookie.Expires = DateTime.Now.AddYears(-1); string randomCookieValue = GenerateRandomCookieValue(); HttpContext.Current.Session[SessionKeys.RandomCookieValue] = randomCookieValue; Response.Cookies.Add(authenticateCookie); SetUserRoles(string.Empty); HttpContext.Current.Session[SessionKeys.ModuleCss] = new List <CssScriptInfo>(); HttpContext.Current.Session[SessionKeys.ModuleJs] = new List <CssScriptInfo>(); Response.Redirect(GetHostURL() + "/" + tempPageName.Replace(" ", "-")); }
private void SagePageLoadPart() { if (!IsPostBack) { string sageNavigateUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); if (!IsParent) { sageNavigateUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + Extension; } else { sageNavigateUrl = GetParentURL + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + Extension; } hypPreview.NavigateUrl = sageNavigateUrl; Image imgProgress = (Image)UpdateProgress1.FindControl("imgPrgress"); if (imgProgress != null) { imgProgress.ImageUrl = GetAdminImageUrl("ajax-loader.gif", true); } } SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; if (string.IsNullOrEmpty(sessionTracker.PortalID)) { sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = GetUsername; SageFrameConfig sfConfig = new SageFrameConfig(); sessionTracker.InsertSessionTrackerPages = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.InsertSessionTrackingPages); SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, GetUsername, GetPortalID.ToString()); Session[SessionKeys.Tracker] = sessionTracker; } }
protected void Session_Start(object sender, EventArgs e) { try { HttpContext.Current.Session["ModuleCss"] = null; HttpContext.Current.Session["ModuleJs"] = null; string IsInstalled = Config.GetSetting("IsInstalled").ToString(); string InstallationDate = Config.GetSetting("InstallationDate").ToString(); if ((IsInstalled != "" && IsInstalled != "false") && InstallationDate != "") { HttpContext.Current.Cache.Remove("SageSetting"); HttpContext.Current.Session["SageFrame.PortalID"] = null; SessionTracker sessionTracker = new SessionTracker(); if (sessionTracker != null) { SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog(); sLog.SessionLogStart(sessionTracker); } HttpContext.Current.Session["Tracker"] = sessionTracker; } } catch { } }
private void LogInPublicModeRegistration() { string strRoles = string.Empty; MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text.Trim()); if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = UserName.Text; Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString()); { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; SecurityPolicy objSecurity = new SecurityPolicy(); HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; cookie.Expires = DateTime.Now.AddMinutes(expiryTime); Response.Cookies.Add(cookie); if (!IsParent) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } else { Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } } } } } }
private void LogInPublicModeRegistration() { string strRoles = string.Empty; MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text); if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = UserName.Text; Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString()); { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName + "_" + GetApplicationName + "_" + GetPortalID, encTicket)); bool IsUseFriendlyUrls = pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } else { Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } } else { Response.Redirect(ResolveUrl("~/Default" + Extension + "?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false); } } } } } }
private void LogInPublicModeRegistration() { string strRoles = string.Empty; MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text); if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = UserName.Text; Session["Tracker"] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); string ReturnUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString()); FormsAuthentication.SetAuthCookie(UserName.Text, true); if (Request.QueryString["ReturnUrl"] != null) { Response.Redirect(ResolveUrl(Request.QueryString["ReturnUrl"].ToString()), false); } else { bool IsUseFriendlyUrls = pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { Response.Redirect("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false); } else { Response.Redirect("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false); } } else { Response.Redirect(ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false); } } } } } }
private void SagePageLoadPart() { LoadGlobalVariables(); if (!IsPostBack) { hypHome.NavigateUrl = sageNavigateUrl; hypHome.Text = sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage); hypHome.ImageUrl = GetTemplateImageUrl("home.png", true); hypPreview.NavigateUrl = hypHome.NavigateUrl; Image imgProgress = (Image)UpdateProgress1.FindControl("imgPrgress"); if (imgProgress != null) { imgProgress.ImageUrl = GetTemplateImageUrl("ajax-loader.gif", true); } bool IsAdmin = false; if (HttpContext.Current.User != null) { MembershipUser user = Membership.GetUser(); if (user != null) { string[] sysRoles = SystemSetting.SYSTEM_SUPER_ROLES; foreach (string role in sysRoles) { if (Roles.IsUserInRole(user.UserName, role)) { IsAdmin = true; break; } } } } if (IsAdmin) { divAdminControlPanel.Attributes.Add("style", "display:block"); } else { divAdminControlPanel.Attributes.Add("style", "display:none"); } Session["payMentGateWayRefresh"] = Server.UrlEncode(System.DateTime.Now.ToString()); } SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; if (string.IsNullOrEmpty(sessionTracker.PortalID)) { sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = GetUsername; SageFrameConfig sfConfig = new SageFrameConfig(); sessionTracker.InsertSessionTrackerPages = sfConfig.GetSettingsByKey(SageFrameSettingKeys.InsertSessionTrackingPages); SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, GetUsername, GetPortalID.ToString()); Session["Tracker"] = sessionTracker; } }
/// <summary> /// Sets session tracker values for any thing requested URL. /// </summary> /// <param name="portalID">Portal ID.</param> /// <param name="userName">User's name.</param> public void SetSessionTrackerValues(string portalID, string userName) { //SessionTracker sessionTracker = (SessionTracker)HttpContext.Current.Session[SessionKeys.Tracker]; //if (string.IsNullOrEmpty(sessionTracker.PortalID)) //{ //sessionTracker.PortalID = portalID; //sessionTracker.Username = userName; //SageFrameConfig sfConfig = new SageFrameConfig(); //sessionTracker.InsertSessionTrackerPages = sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.InsertSessionTrackingPages); SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(userName, portalID); //HttpContext.Current.Session[SessionKeys.Tracker] = sessionTracker; // } }
public void SetSessionTrackerValues(string portalID, string userName) { SessionTracker sessionTracker = (SessionTracker)HttpContext.Current.Session[SessionKeys.Tracker]; if (string.IsNullOrEmpty(sessionTracker.PortalID)) { sessionTracker.PortalID = portalID; sessionTracker.Username = userName; SageFrameConfig sfConfig = new SageFrameConfig(); sessionTracker.InsertSessionTrackerPages = sfConfig.GetSettingsByKey(SageFrameSettingKeys.InsertSessionTrackingPages); SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, userName, portalID); HttpContext.Current.Session[SessionKeys.Tracker] = sessionTracker; } }
private void LogInPublicModeRegistration(UserInfo user) { string strRoles = string.Empty; RoleController role = new RoleController(); SageFrameConfig sfConfig = new SageFrameConfig(); string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = user.UserName; Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString()); { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName + "_" + GetApplicationName + "_" + GetPortalID, encTicket)); bool IsUseFriendlyUrls = sfConfig.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false); } else { Response.Redirect(ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false); } } else { Response.Redirect(ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false); } } } }
private void LogInPublicModeRegistration(UserInfo user) { string strRoles = string.Empty; RoleController role = new RoleController(); SageFrameConfig sfConfig = new SageFrameConfig(); string userRoles = role.GetRoleIDs(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = user.UserName; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SageFrameConfig SageConfig = new SageFrameConfig(); SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension); bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.EnableSessionTracker)); if (EnableSessionTracker) { SLog.SessionTrackerUpdateUsername(user.UserName, GetPortalID.ToString()); } { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. SecurityPolicy objSecurity = new SecurityPolicy(); Response.Cookies.Add(new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket)); if (!IsParent) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false); } else { Response.Redirect(ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false); } } } }
private void SagePageLoadPart() { try { CreateGlobalVariables(); if (!IsPostBack) { hypHome.NavigateUrl = sageNavigateUrl; hypHome.Text = sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage); hypHome.ImageUrl = GetTemplateImageUrl("home.png", true); hypPreview.NavigateUrl = hypHome.NavigateUrl; Image imgProgress = (Image)UpdateProgress1.FindControl("imgPrgress"); if (imgProgress != null) { imgProgress.ImageUrl = GetTemplateImageUrl("ajax-loader.gif", true); } } if ((SessionTracker)Session["Tracker"] != null) { SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; if (string.IsNullOrEmpty(sessionTracker.PortalID)) { sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = GetUsername; SageFrameConfig sfConfig = new SageFrameConfig(); sessionTracker.InsertSessionTrackerPages = sfConfig.GetSettingsByKey(SageFrameSettingKeys.InsertSessionTrackingPages); SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, GetUsername, GetPortalID.ToString()); SLog.StoreSessionTrackerAdd(sessionTracker, GetStoreID, GetPortalID); Session["Tracker"] = sessionTracker; } } //if ((StoreSettingInfo)Session["DefaultStoreSettings"] == null) //{ // AspxCommerceWebService AspxCommerceWebService = new AspxCommerceWebService(); // StoreSettingInfo DefaultStoreSettings = AspxCommerceWebService.GetAllStoreSettings(GetStoreID, GetPortalID, GetCurrentCultureName); // Session["DefaultStoreSettings"] = DefaultStoreSettings; //} } catch { } }
protected void Session_End(object sender, EventArgs e) { try { SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; if ((sessionTracker == null)) { return; } else { SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog(); sLog.SessionLogEnd(sessionTracker); } } catch { } }
protected void SucessFullLogin(UserInfo user) { RoleController role = new RoleController(); Session[SessionKeys.LoginHitCount] = null; string userRoles = role.GetRoleIDs(user.UserName, GetPortalID); if (userRoles.Length > 0) { SetUserRoles(userRoles); MembershipController member = new MembershipController(); user.LastLoginDate = DateTime.UtcNow; string prevLogin = member.UpdateUserLoginActivity(user); HttpContext.Current.Session[SessionKeys.Last_login_Date] = prevLogin; //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = UserName.Text; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString()); StringBuilder redirectURL = new StringBuilder(); SecurityPolicy objSecurity = new SecurityPolicy(); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); //generate random cookieValue string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; //create new cookie with random cookie name and encrypted ticket HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); //get default time from setting SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; //set cookie expiry time cookie.Expires = DateTime.Now.AddMinutes(expiryTime); //add cookie to the browser Response.Cookies.Add(cookie); string roleRedirectURL = string.Empty; roleRedirectURL = member.GetRedirectUrlByRoleID(userRoles); if (roleRedirectURL == string.Empty || roleRedirectURL == null) { roleRedirectURL = PortalAPI.DefaultPageWithExtension; } if (Request.QueryString["ReturnUrl"] != null) { string PageNotFoundPage = PortalAPI.PageNotFoundURLWithRoot; string UserRegistrationPage = PortalAPI.RegistrationURLWithRoot; string PasswordRecoveryPage = PortalAPI.PasswordRecoveryURLWithRoot; string ForgotPasswordPage = PortalAPI.ForgotPasswordURL; string PageNotAccessiblePage = PortalAPI.PageNotAccessibleURLWithRoot; string ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); bool IsWellFormedReturnUrlPage = Uri.IsWellFormedUriString(ReturnUrlPage, UriKind.Absolute); string RequestURL = Request.Url.ToString(); Uri RequestURLPageUri = new Uri(RequestURL); string portalHostURL = RequestURLPageUri.AbsolutePath.TrimStart('/'); if (IsWellFormedReturnUrlPage) { Uri ReturnUrlPageUri = new Uri(ReturnUrlPage); string ReturnURl = ReturnUrlPageUri.Scheme + Uri.SchemeDelimiter + ReturnUrlPageUri.Host + ":" + ReturnUrlPageUri.Port; string HostUrl = GetHostURL(); Uri uriHostURL = new Uri(HostUrl); Uri uriReturnURL = new Uri(ReturnURl); var resultCompareURL = Uri.Compare(uriHostURL, uriReturnURL, UriComponents.Host | UriComponents.PathAndQuery, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase); int resultComparePortalURL = 0; if (portalHostURL.ToLower().Contains("portal") && resultCompareURL == 0) { Uri ReturnUrlPageHostUri = new Uri(ReturnUrlPage); string portalReturnURL = ReturnUrlPageHostUri.AbsolutePath.TrimStart('/'); string[] portalReturnURLSplit = portalReturnURL.Split('/'); string ReturnURLSplitPortal = portalReturnURLSplit[0]; string ReturnURLSplitPortalName = portalReturnURLSplit[1]; string ReturnURLWithPortal = ReturnURLSplitPortal + "/" + ReturnURLSplitPortalName; string[] portalHostURLSplit = portalHostURL.Split('/'); string HostURLSplitPortal = portalHostURLSplit[0]; string HostURLSplitPortalName = portalHostURLSplit[1]; string HostURLWithPortal = HostURLSplitPortal + "/" + HostURLSplitPortalName; resultComparePortalURL = string.Compare(ReturnURLWithPortal, HostURLWithPortal); } if (resultCompareURL != 0 || resultComparePortalURL != 0) { PageNotFoundURL(); } } else { PageNotFoundURL(); } if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage) { redirectURL.Append(GetParentURL); redirectURL.Append(roleRedirectURL); } else { redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString())); } } else { if (!IsParent) { redirectURL.Append(GetParentURL); redirectURL.Append("/portal/"); redirectURL.Append(GetPortalSEOName); redirectURL.Append("/"); redirectURL.Append(roleRedirectURL); } else { redirectURL.Append(GetParentURL); // redirectURL.Append("/Webbuilder/"); redirectURL.Append("/"); redirectURL.Append(roleRedirectURL); } } HttpContext.Current.Session[SessionKeys.IsLoginClick] = true; if (Session[SessionKeys.LoginHitCount] != null) { HttpContext.Current.Session.Remove(SessionKeys.LoginHitCount); } Response.Redirect(redirectURL.ToString(), false); } else { FailureText.Text = string.Format("<span class='sfError'>{0}</span>", GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal"));//"You are not authenticated to this portal!"; } }
protected void lnkloginStatus_Click(object sender, EventArgs e) { try { SageFrameConfig SageConfig = new SageFrameConfig(); SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension); bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingsByKey(SageFrameSettingKeys.EnableSessionTracker)); SessionTracker sessionTrackerNew = new SessionTracker(); if (EnableSessionTracker) { string sessionID = HttpContext.Current.Session.SessionID; SageFrame.Web.SessionLog sLogNew = new SageFrame.Web.SessionLog(); sLogNew.SessionLogStart(sessionTrackerNew, sessionID); } string ReturnUrl = string.Empty; string RedUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); if (lnkloginStatus.CommandName == "LOGIN") { if (Request.QueryString["ReturnUrl"] == null) { ReturnUrl = Request.RawUrl.ToString(); if (!(ReturnUrl.ToLower().Contains(SageFrameSettingKeys.PageExtension))) { //ReturnUrl = ReturnUrl.Remove(strURL.LastIndexOf('/')); if (ReturnUrl.EndsWith("/")) { ReturnUrl += sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } else { ReturnUrl += '/' + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } } } else { ReturnUrl = Request.QueryString["ReturnUrl"].ToString(); } if (!IsParent) { RedUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension; } else { RedUrl = GetParentURL + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension; } } else { if (EnableSessionTracker) { SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog(); sLog.SessionLogEnd(GetPortalID); } SecurityPolicy objSecurity = new SecurityPolicy(); HttpCookie authenticateCookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID)); authenticateCookie.Expires = DateTime.Now.AddYears(-1); string randomCookieValue = GenerateRandomCookieValue(); HttpContext.Current.Session[SessionKeys.RandomCookieValue] = randomCookieValue; Response.Cookies.Add(authenticateCookie); lnkloginStatus.Text = "Login"; SetUserRoles(string.Empty); //create new sessionID SessionIDManager manager = new SessionIDManager(); manager.RemoveSessionID(System.Web.HttpContext.Current); var newId = manager.CreateSessionID(System.Web.HttpContext.Current); var isRedirected = true; var isAdded = true; manager.SaveSessionID(System.Web.HttpContext.Current, newId, out isRedirected, out isAdded); if (!IsParent) { RedUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } else { RedUrl = GetParentURL + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } } CheckOutHelper cHelper = new CheckOutHelper(); cHelper.ClearSessions(); FormsAuthentication.SignOut(); Response.Redirect(RedUrl, false); } catch (Exception ex) { ProcessException(ex); } }
private void LogInPublicModeRegistration(UserInfo user) { string strRoles = string.Empty; RoleController role = new RoleController(); SageFrameConfig sfConfig = new SageFrameConfig(); string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = user.UserName; Session["Tracker"] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString()); { FormsAuthentication.SetAuthCookie(user.UserName, true); bool IsUseFriendlyUrls = sfConfig.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"), false); } else { Response.Redirect(ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"), false); } } else { Response.Redirect(ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false); } } } }
private void LogInPublicModeRegistration(UserInfo user) { string strRoles = string.Empty; RoleController role = new RoleController(); SageFrameConfig sfConfig = new SageFrameConfig(); string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = user.UserName; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SageFrameConfig SageConfig = new SageFrameConfig(); SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension); bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.EnableSessionTracker)); if (EnableSessionTracker) { SLog.SessionTrackerUpdateUsername(user.UserName, GetPortalID.ToString()); } { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. SecurityPolicy objSecurity = new SecurityPolicy(); Response.Cookies.Add(new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket)); if (!IsParent) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false); } else { Response.Redirect(ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false); } } } }
private void LogInPublicModeRegistration() { string strRoles = string.Empty; MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text.Trim()); if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = UserName.Text; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SageFrameConfig SageConfig = new SageFrameConfig(); SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension); bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.EnableSessionTracker)); if (EnableSessionTracker) { SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString()); } { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); StoreSettingConfig ssc = new StoreSettingConfig(); if (ssc.GetStoreSettingsByKey(StoreSetting.AllowRealTimeNotifications, GetStoreID, GetPortalID, GetCurrentCultureName).ToLower() == "true") { RealTimeHelper.UpdateAdminNotifications(GetStoreID, GetPortalID); } // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; SecurityPolicy objSecurity = new SecurityPolicy(); HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; cookie.Expires = DateTime.Now.AddMinutes(expiryTime); Response.Cookies.Add(cookie); string sessionCode = string.Empty; ServiceSecurity.IssueToken(GetPortalID); if (HttpContext.Current.Session.SessionID != null) { sessionCode = HttpContext.Current.Session.SessionID.ToString(); } int CustomerID = GetUserDetailsByUserName(UserName.Text, GetPortalID).CustomerID; UpdateCartAnonymoususertoRegistered(GetStoreID, GetPortalID, CustomerID, sessionCode); if (!IsParent) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } else { Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } } } } } }
protected void Session_Start(object sender, EventArgs e) { try { HttpContext.Current.Session[SessionKeys.ModuleCss] = new List<CssScriptInfo>(); HttpContext.Current.Session[SessionKeys.ModuleJs] = new List<CssScriptInfo>(); ApplicationController objAppController = new ApplicationController(); if (objAppController.IsInstalled()) { HttpContext.Current.Session[SessionKeys.SageFrame_PortalID] = null; Session[SessionKeys.SageFrame_PortalID] = null; Session[SessionKeys.SageFrame_PortalSEOName] = null; SessionTracker sessionTracker = new SessionTracker(); if (sessionTracker != null) { SessionLog sLog = new SessionLog(); sLog.SessionLogStart(sessionTracker); } HttpContext.Current.Session[SessionKeys.Tracker] = sessionTracker; } } catch { } }
protected void SucessFullLogin(UserInfo user) { RoleController role = new RoleController(); Session[SessionKeys.LoginHitCount] = null; string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = UserName.Text; Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString()); StringBuilder redirectURL = new StringBuilder(); if (Request.QueryString["ReturnUrl"] != null) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName + "_" + GetApplicationName + "_" + GetPortalID, encTicket)); string PageNotFoundPage = PortalAPI.PageNotFoundURLWithRoot; string UserRegistrationPage = PortalAPI.RegistrationURLWithRoot; string PasswordRecoveryPage = PortalAPI.PasswordRecoveryURLWithRoot; string ForgotPasswordPage = PortalAPI.ForgotPasswordURL; string PageNotAccessiblePage = PortalAPI.PageNotAccessibleURLWithRoot; string ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage) { redirectURL.Append("~/"); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString())); } } else { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName + "_" + GetApplicationName + "_" + GetPortalID, encTicket)); if (GetPortalID > 1) { redirectURL.Append("~/portal/"); redirectURL.Append(GetPortalSEOName); redirectURL.Append("/"); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append("~/"); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } } HttpContext.Current.Session["IsLoginClick" + user.UserName] = true; Response.Redirect(redirectURL.ToString(), false); } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal"));//"You are not authenticated to this portal!"; } }
protected void SucessFullLogin(UserInfo user) { RoleController role = new RoleController(); Session[SessionKeys.LoginHitCount] = null; string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = UserName.Text; Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString()); StringBuilder redirectURL = new StringBuilder(); SecurityPolicy objSecurity = new SecurityPolicy(); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); //generate random cookieValue string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; //create new cookie with random cookie name and encrypted ticket HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); //get default time from setting SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; //set cookie expiry time cookie.Expires = DateTime.Now.AddMinutes(expiryTime); //add cookie to the browser Response.Cookies.Add(cookie); if (Request.QueryString["ReturnUrl"] != null) { string PageNotFoundPage = PortalAPI.PageNotFoundURLWithRoot; string UserRegistrationPage = PortalAPI.RegistrationURLWithRoot; string PasswordRecoveryPage = PortalAPI.PasswordRecoveryURLWithRoot; string ForgotPasswordPage = PortalAPI.ForgotPasswordURL; string PageNotAccessiblePage = PortalAPI.PageNotAccessibleURLWithRoot; string ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage) { redirectURL.Append(GetParentURL); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString())); } } else { if (!IsParent) { redirectURL.Append(GetParentURL); redirectURL.Append("/portal/"); redirectURL.Append(GetPortalSEOName); redirectURL.Append("/"); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append(GetParentURL); redirectURL.Append("/"); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } } HttpContext.Current.Session["IsLoginClick" + user.UserName] = true; Response.Redirect(redirectURL.ToString(), false); } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal"));//"You are not authenticated to this portal!"; } }
private void SagePageLoadPart() { try { if (!IsPostBack) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalServicePath", " var aspxservicePath='" + ResolveUrl("~/") + "Modules/ASPXCommerce/ASPXCommerceServices/" + "';", true); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalRootPath", " var aspxRootPath='" + ResolveUrl("~/") + "';", true); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalTemplateFolderPath", " var aspxTemplateFolderPath='" + ResolveUrl("~/") + "Templates/" + TemplateName + "';", true); SageFrameConfig sfConfig = new SageFrameConfig(); IsUseFriendlyUrls = sfConfig.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); string sageRedirectPath = string.Empty; string sageNavigateUrl = string.Empty; if (IsUseFriendlyUrls) { if (GetPortalID > 1) { sageRedirectPath = ResolveUrl("~/portal/" + GetPortalSEOName + "/"); sageNavigateUrl = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"); } else { sageRedirectPath = ResolveUrl("~/"); sageNavigateUrl = ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"); } } else { sageRedirectPath = ResolveUrl("{~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)); sageNavigateUrl = ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)); } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalRedirectPath", " var aspxRedirectPath='" + sageRedirectPath + "';", true); hypHome.NavigateUrl = sageNavigateUrl; hypHome.Text = sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage); hypHome.ImageUrl = GetTemplateImageUrl("home.png", true); hypPreview.NavigateUrl = hypHome.NavigateUrl; Image imgProgress = (Image)UpdateProgress1.FindControl("imgPrgress"); if (imgProgress != null) { imgProgress.ImageUrl = GetTemplateImageUrl("ajax-loader.gif", true); } } if ((SessionTracker)Session["Tracker"] != null) { SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; if (string.IsNullOrEmpty(sessionTracker.PortalID)) { sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = GetUsername; SageFrameConfig sfConfig = new SageFrameConfig(); sessionTracker.InsertSessionTrackerPages = sfConfig.GetSettingsByKey(SageFrameSettingKeys.InsertSessionTrackingPages); SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, GetUsername, GetPortalID.ToString()); SLog.StoreSessionTrackerAdd(sessionTracker, GetStoreID, GetPortalID); Session["Tracker"] = sessionTracker; } } if ((StoreSettingInfo)Session["DefaultStoreSettings"] == null) { ASPXCommerceWebService aspxCommerceWebService = new ASPXCommerceWebService(); StoreSettingInfo DefaultStoreSettings = aspxCommerceWebService.GetAllStoreSettings(GetStoreID, GetPortalID, GetCurrentCultureName); Session["DefaultStoreSettings"] = DefaultStoreSettings; } } catch { } }
protected void LoginButton_Click(object sender, EventArgs e) { MembershipController member=new MembershipController(); RoleController role=new RoleController(); UserInfo user=member.GetUserDetails(GetPortalID,UserName.Text); if (user.UserExists && user.IsApproved) { if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = UserName.Text; Session["Tracker"] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString()); if (Request.QueryString["ReturnUrl"] != null) { FormsAuthentication.SetAuthCookie(UserName.Text, RememberMe.Checked); string PageNotFoundPage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalPageNotFound) + ".aspx").Replace("\\", "/"); ; string UserRegistrationPage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalRegistrationPage) + ".aspx").Replace("\\", "/"); ; string PasswordRecoveryPage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalPasswordRecovery) + ".aspx").Replace("\\", "/"); ; string ForgotPasswordPage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalForgotPassword) + ".aspx").Replace("\\", "/"); ; string PageNotAccessiblePage = Path.Combine(this.Request.ApplicationPath.ToString(), pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalPageNotAccessible) + ".aspx").Replace("\\", "/"); ; string ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage) { Response.Redirect("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false); } else { Response.Redirect(ResolveUrl(Request.QueryString["ReturnUrl"].ToString()), false); } } else { FormsAuthentication.SetAuthCookie(UserName.Text, RememberMe.Checked); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { Response.Redirect("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false); } else { Response.Redirect("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx", false); } } else { Response.Redirect(ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false); } } } else { FailureText.Text = GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal");//"You are not authenticated to this portal!"; } } else { FailureText.Text = GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched");//"Username and Password combination doesn't matched!"; } } } else { FailureText.Text = GetSageMessage("UserLogin", "UserDoesnotExist"); } }
protected void SucessFullLogin(UserInfo user) { RoleController role = new RoleController(); Session[SessionKeys.LoginHitCount] = null; string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = UserName.Text; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString()); StringBuilder redirectURL = new StringBuilder(); SecurityPolicy objSecurity = new SecurityPolicy(); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); //generate random cookieValue string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; //create new cookie with random cookie name and encrypted ticket HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); //get default time from setting SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; //set cookie expiry time cookie.Expires = DateTime.Now.AddMinutes(expiryTime); //add cookie to the browser Response.Cookies.Add(cookie); ServiceSecurity.IssueToken(GetPortalID); if (Request.QueryString["ReturnUrl"] != null) { string PageNotFoundPage = PortalAPI.PageNotFoundURLWithRoot; string UserRegistrationPage = PortalAPI.RegistrationURLWithRoot; string PasswordRecoveryPage = PortalAPI.PasswordRecoveryURLWithRoot; string ForgotPasswordPage = PortalAPI.ForgotPasswordURL; string PageNotAccessiblePage = PortalAPI.PageNotAccessibleURLWithRoot; string ReturnUrlPage = string.Empty; if (Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString().Contains(GetHostURL())) { ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); } else { ReturnUrlPage = GetHostURL() + Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); } string RequestURL = Request.Url.ToString(); Uri RequestURLPageUri = new Uri(RequestURL); string portalHostURL = RequestURLPageUri.AbsolutePath.TrimStart('/'); if (GetApplicationName==string.Empty) { bool IsWellFormedReturnUrlPage = Uri.IsWellFormedUriString(ReturnUrlPage, UriKind.Absolute); if (IsWellFormedReturnUrlPage) { Uri ReturnUrlPageUri = new Uri(ReturnUrlPage); string ReturnURl = ReturnUrlPageUri.Scheme + Uri.SchemeDelimiter + ReturnUrlPageUri.Host + ":" + ReturnUrlPageUri.Port; string HostUrl = GetHostURL(); Uri uriHostURL = new Uri(HostUrl); Uri uriReturnURL = new Uri(ReturnURl); var resultCompareURL = Uri.Compare(uriHostURL, uriReturnURL, UriComponents.Host | UriComponents.PathAndQuery, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase); int resultComparePortalURL = 0; if (portalHostURL.ToLower().Contains("portal") && resultCompareURL == 0) { Uri ReturnUrlPageHostUri = new Uri(ReturnUrlPage); string portalReturnURL = ReturnUrlPageHostUri.AbsolutePath.TrimStart('/'); string[] portalReturnURLSplit = portalReturnURL.Split('/'); string ReturnURLSplitPortal = portalReturnURLSplit[0]; string ReturnURLSplitPortalName = portalReturnURLSplit[1]; string ReturnURLWithPortal = ReturnURLSplitPortal + "/" + ReturnURLSplitPortalName; string[] portalHostURLSplit = portalHostURL.Split('/'); string HostURLSplitPortal = portalHostURLSplit[0]; string HostURLSplitPortalName = portalHostURLSplit[1]; string HostURLWithPortal = HostURLSplitPortal + "/" + HostURLSplitPortalName; resultComparePortalURL = string.Compare(ReturnURLWithPortal, HostURLWithPortal); } if (resultCompareURL != 0 || resultComparePortalURL != 0) { PageNotFoundURL(); } } else { PageNotFoundURL(); } } if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage) { redirectURL.Append(GetParentURL); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString())); } } else { if (!IsParent) { redirectURL.Append(GetParentURL); redirectURL.Append("/portal/"); redirectURL.Append(GetPortalSEOName); redirectURL.Append("/"); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append(GetParentURL); redirectURL.Append("/"); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } } HttpContext.Current.Session[SessionKeys.IsLoginClick] = true; if (Session[SessionKeys.LoginHitCount] != null) { HttpContext.Current.Session.Remove(SessionKeys.LoginHitCount); } Response.Redirect(redirectURL.ToString(), false); } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal"));//"You are not authenticated to this portal!"; } }
private void SagePageLoadPart() { if (!IsPostBack) { string sageNavigateUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { sageNavigateUrl = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + Extension); } else { sageNavigateUrl = ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + Extension); } } else { sageNavigateUrl = ResolveUrl("~/Default" + Extension + "?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-")); } hypPreview.NavigateUrl = sageNavigateUrl; Image imgProgress = (Image)UpdateProgress1.FindControl("imgPrgress"); if (imgProgress != null) { imgProgress.ImageUrl = GetAdminImageUrl("ajax-loader.gif", true); } } SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; if (string.IsNullOrEmpty(sessionTracker.PortalID)) { sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = GetUsername; SageFrameConfig sfConfig = new SageFrameConfig(); sessionTracker.InsertSessionTrackerPages = sfConfig.GetSettingsByKey(SageFrameSettingKeys.InsertSessionTrackingPages); SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, GetUsername, GetPortalID.ToString()); Session[SessionKeys.Tracker] = sessionTracker; } }
protected void lnkloginStatus_Click(object sender, EventArgs e) { try { ///Update the Session Tracker SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; if (sessionTracker != null) { SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog(); sLog.SessionLogEnd(sessionTracker); } SessionTracker sessionTrackerNew = new SessionTracker(); if (sessionTrackerNew != null) { SageFrame.Web.SessionLog sLogNew = new SageFrame.Web.SessionLog(); sLogNew.SessionLogStart(sessionTrackerNew); } HttpContext.Current.Session[SessionKeys.Tracker] = sessionTrackerNew; string ReturnUrl = string.Empty; string RedUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); if (lnkloginStatus.CommandName == "LOGIN") { if (IsUseFriendlyUrls) { if (Request.QueryString["ReturnUrl"] == null) { ReturnUrl = Request.RawUrl.ToString(); if (!(ReturnUrl.ToLower().Contains(SageFrameSettingKeys.PageExtension))) { //ReturnUrl = ReturnUrl.Remove(strURL.LastIndexOf('/')); if (ReturnUrl.EndsWith("/")) { ReturnUrl += sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } else { ReturnUrl += '/' + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } } } else { ReturnUrl = Request.QueryString["ReturnUrl"].ToString(); } if (GetPortalID > 1) { RedUrl = "~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension; } else { RedUrl = "~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension; } } else { string[] arrUrl; string strURL = string.Empty; arrUrl = Request.RawUrl.Split('?'); string[] keys = Request.QueryString.AllKeys; for (int i = 0; i < Request.QueryString.Count; i++) { string[] values = Request.QueryString.GetValues(i); strURL += keys[i] + '=' + values[0] + '&'; } if (strURL.Length > 0) { strURL = strURL.Remove(strURL.LastIndexOf('&')); } ReturnUrl = arrUrl[0] + Server.UrlEncode(strURL.Length > 0 ? "?" + strURL : ""); RedUrl = "~/Default" + Extension + "?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + "&ReturnUrl=" + ReturnUrl; } } else { // FormsAuthentication.SignOut(); HttpCookie authenticateCookie = new HttpCookie(FormsAuthentication.FormsCookieName + "_" + GetApplicationName + "_" + GetPortalID); authenticateCookie.Expires = DateTime.Now.AddYears(-1); Response.Cookies.Add(authenticateCookie); lnkloginStatus.Text = "Login"; SetUserRoles(string.Empty); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { RedUrl = "~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } else { RedUrl = "~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } } else { RedUrl = "~/Default" + Extension + "?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-"); } } Response.Redirect(RedUrl, false); } catch (Exception ex) { ProcessException(ex); } }
protected void btnBackup_Click(object sender, EventArgs e) { SessionLog sTracController = new SessionLog(); sTracController.CreateBackup(); }
private void SagePageLoadPart() { if (!IsPostBack) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalServicePath", " var aspxservicePath='" + ResolveUrl("~/") + "Modules/ASPXCommerce/ASPXCommerceServices/" + "';", true); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalRootPath", " var aspxRootPath='" + ResolveUrl("~/") + "';", true); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalTemplateFolderPath", " var aspxTemplateFolderPath='" + ResolveUrl("~/") + "Templates/" + TemplateName + "';", true); string sageRedirectPath = string.Empty; string sageNavigateUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { sageRedirectPath = ResolveUrl("~/portal/" + GetPortalSEOName + "/"); sageNavigateUrl = ResolveUrl("~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"); } else { sageRedirectPath = ResolveUrl("~/"); sageNavigateUrl = ResolveUrl("~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"); } } else { sageRedirectPath = ResolveUrl("{~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm="); sageNavigateUrl = ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)); } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalRedirectPath", " var aspxRedirectPath='" + sageRedirectPath + "';", true); hypHome.NavigateUrl = sageNavigateUrl; hypHome.Text = sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage); hypHome.ImageUrl = GetTemplateImageUrl("home.png", true); hypPreview.NavigateUrl = hypHome.NavigateUrl; Image imgProgress = (Image)UpdateProgress1.FindControl("imgPrgress"); if (imgProgress != null) { imgProgress.ImageUrl = GetTemplateImageUrl("ajax-loader.gif", true); } bool IsAdmin = false; if (HttpContext.Current.User != null) { MembershipUser user = Membership.GetUser(); if (user != null) { string[] sysRoles = SystemSetting.SYSTEM_SUPER_ROLES; foreach (string role in sysRoles) { if (Roles.IsUserInRole(user.UserName, role)) { IsAdmin = true; break; } } } } if (IsAdmin) { divAdminControlPanel.Attributes.Add("style", "display:block"); } else { divAdminControlPanel.Attributes.Add("style", "display:none"); } } SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; if (string.IsNullOrEmpty(sessionTracker.PortalID)) { sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = GetUsername; SageFrameConfig sfConfig = new SageFrameConfig(); sessionTracker.InsertSessionTrackerPages = sfConfig.GetSettingsByKey(SageFrameSettingKeys.InsertSessionTrackingPages); SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, GetUsername, GetPortalID.ToString()); Session["Tracker"] = sessionTracker; } }
protected void Session_End(object sender, EventArgs e) { try { SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; FormsAuthentication.SignOut(); if ((sessionTracker == null)) { return; } else { SessionLog sLog = new SessionLog(); sLog.SessionLogEnd(sessionTracker); } } catch { } if (HttpContext.Current != null) { if (null != HttpContext.Current.Session) HttpContext.Current.Session.Abandon(); } }
protected void lnkloginStatus_Click(object sender, EventArgs e) { try { ///Update the Session Tracker SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog(); sLog.SessionLogEnd(sessionTracker); SessionTracker sessionTrackerNew = new SessionTracker(); if (sessionTrackerNew != null) { SageFrame.Web.SessionLog sLogNew = new SageFrame.Web.SessionLog(); sLogNew.SessionLogStart(sessionTrackerNew); } HttpContext.Current.Session["Tracker"] = sessionTrackerNew; string ReturnUrl = string.Empty; string RedUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); if (lnkloginStatus.CommandName == "LOGIN") { if (IsUseFriendlyUrls) { if (Request.QueryString["ReturnUrl"] == null) { ReturnUrl = Request.RawUrl.ToString(); if (!(ReturnUrl.ToLower().Contains(".aspx"))) { //ReturnUrl = ReturnUrl.Remove(strURL.LastIndexOf('/')); if (ReturnUrl.EndsWith("/")) { ReturnUrl += sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"; } else { ReturnUrl += '/' + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"; } } } else { ReturnUrl = Request.QueryString["ReturnUrl"].ToString(); } if (GetPortalID > 1) { RedUrl = "~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + ".aspx?ReturnUrl=" + ReturnUrl; } else { RedUrl = "~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + ".aspx?ReturnUrl=" + ReturnUrl; } } else { string[] arrUrl; string strURL = string.Empty; arrUrl = Request.RawUrl.Split('?'); string[] keys = Request.QueryString.AllKeys; for (int i = 0; i < Request.QueryString.Count; i++) { string[] values = Request.QueryString.GetValues(i); if (values != null) strURL += keys[i] + '=' + values[0] + '&'; } if (strURL.Length > 0) { strURL = strURL.Remove(strURL.LastIndexOf('&')); } ReturnUrl = arrUrl[0] + Server.UrlEncode(strURL.Length > 0 ? "?" + strURL : ""); //Response.Redirect("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + "&ReturnUrl=" + (Request.QueryString["pgnm"] == null ? pb.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) : Request.QueryString["pgnm"].ToString())); RedUrl = "~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + "&ReturnUrl=" + ReturnUrl; } } else { //TODO:: Clear the session HERE RegenerateSessionID(); FormsAuthentication.SignOut(); lnkloginStatus.Text = "Login"; SetUserRoles(string.Empty); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { RedUrl = "~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"; } else { RedUrl = "~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"; } } else { RedUrl = "~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage); } } Response.Redirect(RedUrl, false); } catch (Exception ex) { ProcessException(ex); } }
protected void LoginButton_Click(object sender, EventArgs e) { MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text); if (user.UserExists && user.IsApproved) { if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(PasswordAspx.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, PasswordAspx.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = UserName.Text; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString()); StringBuilder redirectURL = new StringBuilder(); SecurityPolicy objSecurity = new SecurityPolicy(); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); string encTicket = FormsAuthentication.Encrypt(ticket); string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; cookie.Expires = DateTime.Now.AddMinutes(expiryTime); Response.Cookies.Add(cookie); ServiceSecurity.IssueToken(GetPortalID); if (Request.QueryString["ReturnUrl"] != null) { string PageNotFoundPage = PortalAPI.PageNotFoundURLWithRoot; string UserRegistrationPage = PortalAPI.RegistrationURLWithRoot; string PasswordRecoveryPage = PortalAPI.PasswordRecoveryURLWithRoot; string ForgotPasswordPage = PortalAPI.ForgotPasswordURL; string PageNotAccessiblePage = PortalAPI.PageNotAccessibleURLWithRoot; string ReturnUrlPage = Request.QueryString["ReturnUrl"].Replace("%2f", "-").ToString(); if (ReturnUrlPage == PageNotFoundPage || ReturnUrlPage == UserRegistrationPage || ReturnUrlPage == PasswordRecoveryPage || ReturnUrlPage == ForgotPasswordPage || ReturnUrlPage == PageNotAccessiblePage) { redirectURL.Append(GetParentURL); redirectURL.Append(PortalAPI.DefaultPageWithExtension); } else { redirectURL.Append(ResolveUrl(Request.QueryString["ReturnUrl"].ToString())); } } else { if (!IsParent) { redirectURL.Append(GetParentURL); redirectURL.Append("/portal/"); redirectURL.Append(GetPortalSEOName); redirectURL.Append("/"); redirectURL.Append(ssc.GetStoreSettingsByKey(StoreSetting.SingleCheckOutURL, GetStoreID, GetPortalID, GetCurrentCultureName)); redirectURL.Append(SageFrameSettingKeys.PageExtension); } else { redirectURL.Append(GetParentURL); redirectURL.Append("/"); redirectURL.Append(ssc.GetStoreSettingsByKey(StoreSetting.SingleCheckOutURL, GetStoreID, GetPortalID, GetCurrentCultureName)); redirectURL.Append(SageFrameSettingKeys.PageExtension); } } int customerID = GetCustomerID; if (customerID == 0) { CustomerGeneralInfo sageUserCust = CustomerGeneralInfoController.CustomerIDGetByUsername(user.UserName, storeID, portalID); if (sageUserCust != null) { customerID = sageUserCust.CustomerID; } } AspxCommonController objCommonCont = new AspxCommonController(); objCommonCont.UpdateCartAnonymoususertoRegistered(storeID, portalID, customerID, sessionCode); Response.Redirect(redirectURL.ToString(), false); } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "Youarenotauthenticatedtothisportal")); } } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched"));//"Username and Password combination doesn't matched!"; } } } else { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UserDoesnotExist")); } }
protected void lnkloginStatus_Click(object sender, EventArgs e) { try { ///Update the Session Tracker //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //if (sessionTracker != null) //{ // SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog(); // sLog.SessionLogEnd(sessionTracker); //} SageFrameConfig SageConfig = new SageFrameConfig(); SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension); bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingsByKey(SageFrameSettingKeys.EnableSessionTracker)); SessionTracker sessionTrackerNew = new SessionTracker(); if (EnableSessionTracker) { string sessionID = HttpContext.Current.Session.SessionID; SageFrame.Web.SessionLog sLogNew = new SageFrame.Web.SessionLog(); sLogNew.SessionLogStart(sessionTrackerNew, sessionID); } string ReturnUrl = string.Empty; string RedUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); if (lnkloginStatus.CommandName == "LOGIN") { if (Request.QueryString["ReturnUrl"] == null) { ReturnUrl = Request.RawUrl.ToString(); if (!(ReturnUrl.ToLower().Contains(SageFrameSettingKeys.PageExtension))) { //ReturnUrl = ReturnUrl.Remove(strURL.LastIndexOf('/')); if (ReturnUrl.EndsWith("/")) { ReturnUrl += sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } else { ReturnUrl += '/' + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-") + SageFrameSettingKeys.PageExtension; } } } else { ReturnUrl = Request.QueryString["ReturnUrl"].ToString(); } if (!IsParent) { RedUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension; } else { RedUrl = GetParentURL + "/" + sfConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.PortalLoginpage) + SageFrameSettingKeys.PageExtension; } string strCurrentURL = Request.Url.ToString(); if (RedUrl.ToString().Contains("?")) { RedUrl += "&ReturnUrl="; RedUrl += strCurrentURL; } else { RedUrl += "?ReturnUrl="; RedUrl += strCurrentURL; } } else { if (EnableSessionTracker) { SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog(); sLog.SessionLogEnd(GetPortalID); } SecurityPolicy objSecurity = new SecurityPolicy(); HttpCookie authenticateCookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID)); authenticateCookie.Expires = DateTime.Now.AddYears(-1); string randomCookieValue = GenerateRandomCookieValue(); HttpContext.Current.Session[SessionKeys.RandomCookieValue] = randomCookieValue; Response.Cookies.Add(authenticateCookie); lnkloginStatus.Text = "Login"; SetUserRoles(string.Empty); if (!IsParent) { RedUrl = GetParentURL + "/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-"); } else { RedUrl = GetParentURL + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage).Replace(" ", "-"); } } FormsAuthentication.SignOut(); Response.Redirect(RedUrl, false); } catch (Exception ex) { ProcessException(ex); } }
private void LogInPublicModeRegistration() { string strRoles = string.Empty; MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text); if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = UserName.Text; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString()); { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); bool IsUseFriendlyUrls = pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); if (IsUseFriendlyUrls) { if (!IsParent) { Response.Redirect(ResolveUrl(GetParentURL + "/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false); } else { Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + SageFrameSettingKeys.PageExtension), false); } } else { Response.Redirect(ResolveUrl("~/Default"+SageFrameSettingKeys.PageExtension+"?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false); } } } } } }
protected void lnkloginStatus_Click(object sender, EventArgs e) { try { ///Update the Session Tracker SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; SageFrame.Web.SessionLog sLog = new SageFrame.Web.SessionLog(); sLog.SessionLogEnd(sessionTracker); SessionTracker sessionTrackerNew = new SessionTracker(); if (sessionTrackerNew != null) { SageFrame.Web.SessionLog sLogNew = new SageFrame.Web.SessionLog(); sLogNew.SessionLogStart(sessionTrackerNew); } HttpContext.Current.Session["Tracker"] = sessionTrackerNew; string ReturnUrl = string.Empty; string RedUrl = string.Empty; SageFrameConfig sfConfig = new SageFrameConfig(); if (lnkloginStatus.CommandName == "LOGIN") { if (IsUseFriendlyUrls) { if (Request.QueryString["ReturnUrl"] == null) { ReturnUrl = Request.RawUrl.ToString(); if (!(ReturnUrl.ToLower().Contains(".aspx"))) { //ReturnUrl = ReturnUrl.Remove(strURL.LastIndexOf('/')); if (ReturnUrl.EndsWith("/")) { ReturnUrl += sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"; } else { ReturnUrl += '/' + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"; } } } else { ReturnUrl = Request.QueryString["ReturnUrl"].ToString(); } if (GetPortalID > 1) { RedUrl = "~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + ".aspx?ReturnUrl=" + ReturnUrl; } else { RedUrl = "~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + ".aspx?ReturnUrl=" + ReturnUrl; } } else { string[] arrUrl; string strURL = string.Empty; arrUrl = Request.RawUrl.Split('?'); string[] keys = Request.QueryString.AllKeys; for (int i = 0; i < Request.QueryString.Count; i++) { string[] values = Request.QueryString.GetValues(i); if (values != null) { strURL += keys[i] + '=' + values[0] + '&'; } } if (strURL.Length > 0) { strURL = strURL.Remove(strURL.LastIndexOf('&')); } ReturnUrl = arrUrl[0] + Server.UrlEncode(strURL.Length > 0 ? "?" + strURL : ""); //Response.Redirect("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pb.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + "&ReturnUrl=" + (Request.QueryString["pgnm"] == null ? pb.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) : Request.QueryString["pgnm"].ToString())); RedUrl = "~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalLoginpage) + "&ReturnUrl=" + ReturnUrl; } } else { //TODO:: Clear the session HERE RegenerateSessionID(); FormsAuthentication.SignOut(); lnkloginStatus.Text = "Login"; SetUserRoles(string.Empty); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { RedUrl = "~/portal/" + GetPortalSEOName + "/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"; } else { RedUrl = "~/" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"; } } else { RedUrl = "~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage); } } Response.Redirect(RedUrl, false); } catch (Exception ex) { ProcessException(ex); } }
private void LogInPublicModeRegistration() { string strRoles = string.Empty; MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text); if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); SessionTracker sessionTracker = (SessionTracker)Session["Tracker"]; sessionTracker.PortalID = GetPortalID.ToString(); sessionTracker.Username = UserName.Text; Session["Tracker"] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SLog.SessionTrackerUpdateUsername(sessionTracker, sessionTracker.Username, GetPortalID.ToString()); { FormsAuthentication.SetAuthCookie(UserName.Text, true); bool IsUseFriendlyUrls = pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); if (IsUseFriendlyUrls) { if (GetPortalID > 1) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"), false); } else { Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + ".aspx"), false); } } else { Response.Redirect(ResolveUrl("~/Default.aspx?ptlid=" + GetPortalID + "&ptSEO=" + GetPortalSEOName + "&pgnm=" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage)), false); } } } } } }
private void LogInPublicModeRegistration() { string strRoles = string.Empty; MembershipController member = new MembershipController(); RoleController role = new RoleController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text.Trim()); if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { string userRoles = role.GetRoleNames(user.UserName, GetPortalID); strRoles += userRoles; if (strRoles.Length > 0) { SetUserRoles(strRoles); //SessionTracker sessionTracker = (SessionTracker)Session[SessionKeys.Tracker]; //sessionTracker.PortalID = GetPortalID.ToString(); //sessionTracker.Username = UserName.Text; //Session[SessionKeys.Tracker] = sessionTracker; SageFrame.Web.SessionLog SLog = new SageFrame.Web.SessionLog(); SageFrameConfig SageConfig = new SageFrameConfig(); SageFrameSettingKeys.PageExtension = SageConfig.GetSettingsByKey(SageFrameSettingKeys.SettingPageExtension); bool EnableSessionTracker = bool.Parse(SageConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.EnableSessionTracker)); if (EnableSessionTracker) { SLog.SessionTrackerUpdateUsername(UserName.Text, GetPortalID.ToString()); } { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, GetPortalID.ToString(), FormsAuthentication.FormsCookiePath); StoreSettingConfig ssc = new StoreSettingConfig(); if (ssc.GetStoreSettingsByKey(StoreSetting.AllowRealTimeNotifications, GetStoreID, GetPortalID, GetCurrentCultureName).ToLower() == "true") { RealTimeHelper.UpdateAdminNotifications(GetStoreID, GetPortalID); } // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. string randomCookieValue = GenerateRandomCookieValue(); Session[SessionKeys.RandomCookieValue] = randomCookieValue; SecurityPolicy objSecurity = new SecurityPolicy(); HttpCookie cookie = new HttpCookie(objSecurity.FormsCookieName(GetPortalID), encTicket); SageFrameConfig objConfig = new SageFrameConfig(); string ServerCookieExpiration = objConfig.GetSettingValueByIndividualKey(SageFrameSettingKeys.ServerCookieExpiration); int expiryTime = Math.Abs(int.Parse(ServerCookieExpiration)); expiryTime = expiryTime < 5 ? 5 : expiryTime; cookie.Expires = DateTime.Now.AddMinutes(expiryTime); Response.Cookies.Add(cookie); string sessionCode = string.Empty; ServiceSecurity.IssueToken(GetPortalID); if (HttpContext.Current.Session.SessionID != null) { sessionCode = HttpContext.Current.Session.SessionID.ToString(); } int CustomerID = GetUserDetailsByUserName(UserName.Text,GetPortalID).CustomerID; UpdateCartAnonymoususertoRegistered(GetStoreID, GetPortalID, CustomerID, sessionCode); if (!IsParent) { Response.Redirect(ResolveUrl("~/portal/" + GetPortalSEOName + "/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } else { Response.Redirect(ResolveUrl("~/" + pagebase.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) + Extension), false); } } } } } }