private void UpdateSharedLoggedInUserInfo(ValidateUserLogin validateUserLogin) { Na.Core.SharedInfo _sharedInfo = new Na.Core.SharedInfo(); LoggedInUserInfo objLoggedInUserInfo = new LoggedInUserInfo(); objLoggedInUserInfo.FBUser = validateUserLogin.FBUser; objLoggedInUserInfo.LoginUserMiscInfo = validateUserLogin.LoginUserMiscInfo; objLoggedInUserInfo.User = validateUserLogin.User; objLoggedInUserInfo.UserAccount = validateUserLogin.UserAccount; _sharedInfo.LoggedInUserInfo = objLoggedInUserInfo; }
private bool fcnLogin(LoginModel model, ref User user, ref UserAccountInformation userAccountInfo, int LoginOrReset) { ValidateUserLogin objValidateUserLogin = null; // main class LoginUserMiscInfo objLoginUserMiscInfo = null; // Login validate information UserModel ObjUser = null; UserAccountModel ObjUserAccount = null; string strUsername = model.UserName; string strPassword = model.ResetPassword = model.Password; bool blnLogin = false; //added BY Rakesh Kumar on 13 June 2013 LoginUserData try { objValidateUserLogin = new ValidateUserLogin(); // main class objLoginUserMiscInfo = new LoginUserMiscInfo(); // Login validate information ObjUser = new UserModel(); ObjUserAccount = new UserAccountModel(); // UserAccount information objValidateUserLogin = _loginService.ValidateUserLogin(model.UserName.Trim(), model.Password.Trim(), LoginOrReset, "http://www.newspaperarchive.com", Session.SessionID);////third parameter 0 is for Reset login . //if (objValidateUserLogin != null) if (objValidateUserLogin.User != null && objValidateUserLogin.FBUser != null && objValidateUserLogin.UserAccount != null && objValidateUserLogin.LoginUserMiscInfo != null) { objLoginUserMiscInfo = objValidateUserLogin.LoginUserMiscInfo; ObjUser = objValidateUserLogin.User; ObjUserAccount = objValidateUserLogin.UserAccount; if (ObjUser != null && objLoginUserMiscInfo != null && ObjUserAccount != null) blnLogin = true; } if (blnLogin) { int? LoggedInStatus = objLoginUserMiscInfo.UserIsLive; //var CheckEncryptedLoginCookie = GetCookieValue(".ASPXAUTH"); //Added By Rakesh //if (LoggedInStatus > 0 && string.IsNullOrEmpty(CheckEncryptedLoginCookie)) if (LoggedInStatus > 0) { model.loginMessage = "<div class=\"alert-panel\"><div class=\"alert alert-error\"><button data-dismiss=\"alert\" class=\"close\" type=\"button\">×</button>" + "<b>User already logged in at: " + String.Format("{0:MMM d yyyy}", objLoginUserMiscInfo.LoginTime) + ". Your account is showing you are logged in. More than one person can not be logged in under " + "the same username. Please click on the \"Yes. Log me in and end the other session.\" button.</b></div></div>"; //////////"the same username. Please re-enter your user name and password then click on the reset button.</b></div></div>"; model.isConcurrent = true; blnLogin = false; return blnLogin; } HttpCookie cookies = new HttpCookie(_config.GetStringValueFromConfig("cookiePrefix", "NewspaperARCHIVE.com") + ".shoppingCart"); cookies = Request.Cookies[_config.GetStringValueFromConfig("cookiePrefix", "NewspaperARCHIVE.com") + ".shoppingCart"]; if (cookies != null) { cookies.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(cookies); } //userAccountInfo = _userAccountService.GetActiveAccountByUserId(user.UserId); Na.Core.Cookies.clsCookies clsCookie = new Na.Core.Cookies.clsCookies(); if (objLoginUserMiscInfo == null) { blnLogin = false; } else { // var RoleId = 0; if (objLoginUserMiscInfo.WebsiteID == 1 && objLoginUserMiscInfo.ActiveAccount == 1) { //roleId = Convert.ToInt32(objLoginInformatin.RoleId); //var websiteRole = _webRoles.GetWebsiteRoleById(roleId); String WebsiteRoleName = objLoginUserMiscInfo.WebsiteRoleName; // if Role Name exists then Proceed ahead else escape this conditions if (!string.IsNullOrEmpty(WebsiteRoleName)) { if (ObjUserAccount.EndDate < DateTime.Now) { Response.Cookies.Add(clsCookie.fcnCreateValidationCookie(Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.UserId.ToString()), Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.Password), Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.UserName), objLoginUserMiscInfo.EmailAddress, ObjUser.FirstName, ObjUser.LastName, "7", "Expired", _common.GetStringValue(ObjUserAccount.PlanId, string.Empty), "", ConfigurationManager.AppSettings["cookieTimeout"].ToString(), ConfigurationManager.AppSettings["cookiePrefix"].ToString())); } else { Response.Cookies.Add(clsCookie.fcnCreateValidationCookie(Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.UserId.ToString()), Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.Password), Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.UserName), objLoginUserMiscInfo.EmailAddress, ObjUser.FirstName, ObjUser.LastName, ObjUserAccount.RoleId.ToString(), objLoginUserMiscInfo.WebsiteRoleName, _common.GetStringValue(ObjUserAccount.PlanId, string.Empty), "", ConfigurationManager.AppSettings["cookieTimeout"].ToString(), ConfigurationManager.AppSettings["cookiePrefix"].ToString())); } // int? webSiteIdForURL = objLoginUserMiscInfo.WebSiteIdForReport; //// below functionality is handled by Sproc--by Rakesh Kumar on Dated 13 june 2013 // _userService.ReportUserLogin(objLoginInformatin.UserID, "http://www.newspaperarchive.com", Session.SessionID); } } else { //if (objLoginUserMiscInfo.ActiveAccount >= 0) //{ // Response.Cookies.Add(clsCookie.fcnCreateValidationCookie(Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.UserId.ToString()), Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.Password), Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.UserName), objLoginUserMiscInfo.EmailAddress, ObjUser.FirstName, ObjUser.LastName, "7", "Expired", _common.GetStringValue(ObjUserAccount.PlanId, string.Empty), "", ConfigurationManager.AppSettings["cookieTimeout"].ToString(), ConfigurationManager.AppSettings["cookiePrefix"].ToString())); // blnLogin = true; //} //else //{ Response.Cookies.Add(clsCookie.fcnCreateValidationCookie(Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.UserId.ToString()), Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.Password), Na.Core.Helpers.SecureNPASecurity.Encryption.EncryptText(ObjUser.UserName), objLoginUserMiscInfo.EmailAddress, ObjUser.FirstName, ObjUser.LastName, "7", "Expired", _common.GetStringValue(ObjUserAccount.PlanId, string.Empty), "", ConfigurationManager.AppSettings["cookieTimeout"].ToString(), ConfigurationManager.AppSettings["cookiePrefix"].ToString())); blnLogin = true; //} } } } else { blnLogin = false; Redirect(Na.Core.Configuration.NaConfig.Url.DomainUrl + "/login?value=invalid"); } if (blnLogin) { Session["testUSer"] = model.UserName; UpdateSharedLoggedInUserInfo(objValidateUserLogin); } } //catch (Exception) { } finally { objLoginUserMiscInfo = null; ObjUser = null; ObjUserAccount = null; objValidateUserLogin = null; } return blnLogin; }