private void SetUserRole(int UserId, int OrgId) { UserRequest UserRequest = new UserRequest(); UserRequest.Organization.OrganizationId = OrgId; UserRequest.User.UserId = UserId; var UserRes = _isurveyFacade.GetUserInfo(UserRequest); if (UserRes.User.Count() > 0) { Session["UsertRole"] = UserRes.User[0].Role; } }
public ActionResult UserInfo(int userid, bool iseditmode, int orgid) { string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); ViewBag.Version = version; UserModel UserModel = new UserModel(); UserRequest Request = new UserRequest(); orgid = int.Parse(Session["CurrentOrgId"].ToString()); if (iseditmode) { Request.Organization = new OrganizationDTO(); Request.Organization.OrganizationId = orgid; Request.User = new UserDTO(); Request.User.UserId = userid; UserResponse Response = _isurveyFacade.GetUserInfo(Request); UserModel = Mapper.ToUserModelR(Response.User[0]); UserModel.IsEditMode = true; return(View("UserInfo", UserModel)); } UserModel.IsActive = true; return(View("UserInfo", UserModel)); }
public ActionResult Index(string responseId, string ReturnUrl) { bool useSAMS = false; if (!string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["USE_SAMS_AUTHENTICATION"])) { bool.TryParse(ConfigurationManager.AppSettings["USE_SAMS_AUTHENTICATION"], out useSAMS); } if (useSAMS) { return(Redirect("SignIn")); } string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); UserLoginModel UserLoginModel = new Models.UserLoginModel(); ViewBag.Version = version; SetTermOfUse(); if (ConfigurationManager.AppSettings["IsDemoMode"] != null) { Session["IsDemoMode"] = ConfigurationManager.AppSettings["IsDemoMode"].ToUpper(); } else { Session["IsDemoMode"] = "null"; } // //get the responseId // responseId = GetResponseId(ReturnUrl); // //get the surveyId // string SurveyId = _isurveyFacade.GetSurveyAnswerResponse(responseId).SurveyResponseList[0].SurveyId; // //put surveyId in viewbag so can be retrieved in Login/Index.cshtml // ViewBag.SurveyId = SurveyId; if (System.Configuration.ConfigurationManager.AppSettings["IsDemoMode"] != null) { var IsDemoMode = System.Configuration.ConfigurationManager.AppSettings["IsDemoMode"]; string UserId = Epi.Web.Enter.Common.Security.Cryptography.Encrypt("1"); if (!string.IsNullOrEmpty(IsDemoMode) && IsDemoMode.ToUpper() == "TRUE") { FormsAuthentication.SetAuthCookie("*****@*****.**", false); Session["UserId"] = UserId; Session["UserHighestRole"] = 3; Session["UserFirstName"] = "John"; Session["UserLastName"] = "Doe"; Session["UserEmailAddress"] = "*****@*****.**"; return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, "Home", new { surveyid = "" })); } } var configuration = WebConfigurationManager.OpenWebConfiguration("/"); var authenticationSection = (AuthenticationSection)configuration.GetSection("system.web/authentication"); if (authenticationSection.Mode == AuthenticationMode.Forms) { return(View("Index", UserLoginModel)); } else { try { var CurrentUserName = System.Web.HttpContext.Current.User.Identity.Name; var UserAD = Utility.WindowsAuthentication.GetCurrentUserFromAd(CurrentUserName); // validate user in EWE system UserRequest User = new UserRequest(); User.IsAuthenticated = true; User.User.EmailAddress = UserAD.EmailAddress; UserResponse result = _isurveyFacade.GetUserInfo(User); if (result != null && result.User != null && result.User.Count() > 0) { FormsAuthentication.SetAuthCookie(CurrentUserName.Split('\\')[0].ToString(), false); string UserId = Epi.Web.Enter.Common.Security.Cryptography.Encrypt(result.User[0].UserId.ToString()); Session["UserId"] = UserId; //Session["UsertRole"] = result.User.Role; Session["UserHighestRole"] = result.User[0].UserHighestRole; Session["UserEmailAddress"] = result.User[0].EmailAddress; Session["UserFirstName"] = result.User[0].FirstName; Session["UserLastName"] = result.User[0].LastName; Session["UGuid"] = result.User[0].UGuid; return(RedirectToAction(Epi.Web.MVC.Constants.Constant.INDEX, "Home", new { surveyid = "" })); } else { //return View("Index", UserLoginModel); ViewBag.ErrorName = "--You are not an authorized user of the system.--"; return(View("Error")); } } catch (Exception ex) { //ViewBag.ErrorName = ex.Message; //return View("Error"); return(View("Index", UserLoginModel)); } } }