public ActionResult Index() { try { ConfigurationViewModel orbit = new ConfigurationViewModel(); EmployeeDAL employeeDAL = new EmployeeDAL(); orbit.SearchedUserDetails = new SearchedUserDetails(); ViewBag.AsciiKey = Session["SecurityKey"].ToString(); string employeeCode = Membership.GetUser().UserName; int employeeId = employeeDAL.GetEmployeeID(employeeCode); string[] role = Roles.GetRolesForUser(employeeCode); if (employeeCode != null) { orbit.SearchedUserDetails.EmployeeId = employeeId; SemDAL semdal = new SemDAL(); int employeeid = semdal.geteEmployeeIDFromSEMDatabase(employeeCode); orbit.SearchedUserDetails.IsProjectReviewer = semdal.CheckIfEmployeeisReviewer(employeeid); orbit.SearchedUserDetails.EmployeeCode = employeeCode; orbit.SearchedUserDetails.UserRole = Commondal.GetMaxRoleForUser(role); } return(View(orbit)); } catch { throw; } }
public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { model.UserName = model.UserName.Trim(); if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { string[] role = Roles.GetRolesForUser(model.UserName); if (role == null || role.Count() <= 0) { FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Error", new { errorCode = "Error403" })); } EmployeeDAL employeeDAL = new EmployeeDAL(); SemDAL SEMdal = new SemDAL(); int employeeID = employeeDAL.GetEmployeeID(model.UserName); int semEmployeeId = SEMdal.geteEmployeeIDFromSEMDatabase(model.UserName); Guid globalID = Guid.NewGuid(); Session["LoggedInEmployee"] = model.UserName; Session["LoggedInEmployeeSEMID"] = semEmployeeId; Session["SecurityKey"] = globalID.ToString(); string encryptedEmployeeid = Encrypt(Convert.ToString(Session["SecurityKey"].ToString() + employeeID), true); Session["encryptedLoggedinEmployeeID"] = encryptedEmployeeid; string current_DU = employeeDAL.getCurrentDU(model.UserName); Session["Current_DU"] = current_DU; Session["ViewNode"] = employeeDAL.GetViewableNodesForEmployee(Convert.ToInt32(model.UserName)); CommonMethodsDAL Commondal = new CommonMethodsDAL(); string maxRole = Commondal.GetMaxRoleForUser(role); Session["MaxUserRole"] = maxRole; //for Help desk Tab Access //if (User.IsInRole("Super Admin") == false) // Session // return RedirectToAction("Index", "PersonalDetails", new { employeeId = encryptedEmployeeid }); //return RedirectToAction("Index", "Orbit"); if (HttpContext.User.IsInRole("Super Admin")) { Session["SuperAdmin"] = model.UserName; } else { Session["SuperAdmin"] = 0; } Session["EmployeeID"] = model.UserName; HRMS_tbl_PM_Employee employee = employeeDAL.GetEmployeeDetailsByEmployeeCode(model.UserName); Session["LoggedInEmployeeName"] = employee.EmployeeName; if (employee != null) { Session["UserName"] = employee.FirstName; } //added code for access mapping Session["AccessRights"] = employeeDAL.GetPageAccessMapping(model.UserName); XmlDocument doc = new XmlDocument(); string data = employeeDAL.GetPageAccessMapping_xmlData(model.UserName); doc.LoadXml(data); Session["MenuDataList"] = JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.None, true); return(RedirectPermanent("~/Orbitweb/SignInSignOut.aspx")); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult LogIn() { try { LogOnModel model = new LogOnModel(); string userName = Convert.ToString(Request.Form["UserName"]); userName = userName.Trim(); string password = Convert.ToString(Request.Form["pwd"]); string employeeCode = string.Empty; //if (Session["LoggedInEmployee"] != null) // employeeCode = Session["LoggedInEmployee"].ToString(); //if (employeeCode == "") //{ if (Membership.ValidateUser(userName, password)) { FormsAuthentication.SetAuthCookie(userName, true); string[] role = Roles.GetRolesForUser(userName); if (role == null || role.Count() <= 0) { FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Error", new { errorCode = "Error403" })); } EmployeeDAL employeeDAL = new EmployeeDAL(); SemDAL SEMdal = new SemDAL(); int employeeID = employeeDAL.GetEmployeeID(userName); int semEmployeeId = SEMdal.geteEmployeeIDFromSEMDatabase(userName); Session["LoggedInEmployee"] = userName; Session["LoggedInEmployeeSEMID"] = semEmployeeId; Guid globalID = Guid.NewGuid(); Session["SecurityKey"] = globalID.ToString(); string encryptedEmployeeid = Encrypt(Convert.ToString(Session["SecurityKey"].ToString() + employeeID), true); Session["encryptedLoggedinEmployeeID"] = encryptedEmployeeid; string current_DU = employeeDAL.getCurrentDU(userName); if (string.IsNullOrEmpty(current_DU)) { current_DU = "0"; } Session["Current_DU"] = current_DU; //return RedirectToAction("Index", "PersonalDetails", new { employeeId = encryptedEmployeeid }); ////GoLive code for redirecting to orbit if (HttpContext.User.IsInRole("Super Admin")) { Session["SuperAdmin"] = userName; } else { Session["SuperAdmin"] = 0; } Session["EmployeeID"] = userName; HRMS_tbl_PM_Employee employee = employeeDAL.GetEmployeeDetailsByEmployeeCode(userName); if (employee != null) { Session["UserName"] = employee.FirstName; } //added code for access mapping Session["AccessRights"] = employeeDAL.GetPageAccessMapping(userName); XmlDocument doc = new XmlDocument(); string data = employeeDAL.GetPageAccessMapping_xmlData(userName); doc.LoadXml(data); Session["MenuDataList"] = JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.None, true); return(RedirectPermanent("~/Orbitweb/SignInSignOut.aspx")); } else { model.LogOffURL = System.Configuration.ConfigurationManager.AppSettings["Log-OffURL"]; return(View(model)); } //} //else //{ // model.IsValidSession = false; // return View(model); //} } catch { throw; } }