protected void Session_Start(object sender, EventArgs e) { if (User.Identity.IsAuthenticated) { SiteUtility.SetSessionVariables(User.Identity.Name); } }
public ActionResult LoginAsPrimaryUser(Guid PUseId) { //logout current user if (HttpContext.User.Identity.IsAuthenticated) { Session.Abandon(); FormsService.SignOut(); } //authenticate primary user and set session variables User oUser = new UserBL().GetById(PUseId); FormsService.SignIn(oUser.Email, false); SiteUtility.SetSessionVariables(oUser.Email); //Notification //if (oUser.HomePage == En_HomePage.Case_Management.ToString().Replace("_", " ")) // return RedirectToAction("Index", "Case", new { Area = "Clinic" }); //else if (oUser.HomePage == En_HomePage.System_Dashboard.ToString().Replace("_", " ")) //{ // return RedirectToAction("Index", "Home", new { Area = "Clinic" }); //} //else if (oUser.HomePage == En_HomePage.Finance_Dashboard.ToString().Replace("_", " ")) //{ // return RedirectToAction("Index", "Payments", new { Area = "Clinic" }); //} //else return(RedirectToAction("Index", "Home", new { Area = "Clinic" })); }
//[ValidateAntiForgeryToken] public ActionResult Login(LoginViewModel oLoginViewModel) { try { vw_Users oUser = new UserBL().ValidateUser(oLoginViewModel.Email, oLoginViewModel.Password); if (oUser != null) { string Active = En_User_Status.Active.ToString(); string Inactive = En_User_Status.Inactive.ToString(); if (oUser.Status == Inactive) { ViewBag.Error = "Your Account has been suspended, please contact to site administrator."; return(View()); } else if (oUser.Status == Active) { FormsService.SignIn(oLoginViewModel.Email, oLoginViewModel.RememberMe); SiteUtility.SetSessionVariables(oLoginViewModel.Email); if (oUser.RoleId == (int)En_Role.Primary) { if (oUser.ActivationEndDate < DateTime.UtcNow) { ViewBag.Error = "Your Account has been expired, please contact to site administrator."; return(View()); } //SiteUtility.SetSessionVariables(oUser.Email); //if (oUser.HomePage == En_HomePage.Case_Management.ToString().Replace("_", " ")) // return RedirectToAction("Index", "Case", new { Area = "Clinic" }); //else if (oUser.HomePage == En_HomePage.System_Dashboard.ToString().Replace("_", " ")) //{ // return RedirectToAction("Index", "Home", new { Area = "Clinic" }); //} //else if (oUser.HomePage == En_HomePage.Finance_Dashboard.ToString().Replace("_", " ")) //{ // return RedirectToAction("Index", "Payments", new { Area = "Clinic" }); //} //else return(RedirectToAction("Index", "ShadeCards")); } else { //if (oUser.HomePage == En_HomePage.Case_Management.ToString().Replace("_", " ")) // return RedirectToAction("Index", "Case"); //else if (oUser.HomePage == En_HomePage.Finance_Dashboard.ToString().Replace("_", " ")) //{ // if (SiteUtility.GetCurrentUser().RoleId == (int)En_Role.Specialist) // { // return RedirectToAction("Index", "Case"); // } // return RedirectToAction("Index", "FinanceDashboard"); //} //else if (oUser.HomePage == En_HomePage.System_Dashboard.ToString().Replace("_", " ")) //{ // return RedirectToAction("Index", "Home"); //} //else return(RedirectToAction("Index", "Home", new { Area = "Admin" })); } } } else { ViewBag.Error = "Invalid Email or Password."; } return(View()); } catch (Exception ex) { throw ex; } }