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);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        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);
                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(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!";
            }
        }
예제 #3
0
        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!";
            }
        }
예제 #4
0
    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"));
        }
    }