public ActionResult Login(string id = "") { if (SessionManager.GetUserSession() != null) { return RedirectToAction("Dashboard", "Home"); } else { //id <=> langue : variable from public website to extranet if (!string.IsNullOrEmpty(id)) { SessionManager.ClearAll(); switch (id) { case "FR": SessionManager.SetCurrentLanguage(LanguageTypeBL.GetLanguageTypeByLanguageName(LanguageTypeBL.LanguageTypes.French)); break; case "EN": SessionManager.SetCurrentLanguage(LanguageTypeBL.GetLanguageTypeByLanguageName(LanguageTypeBL.LanguageTypes.English)); break; case "DE": SessionManager.SetCurrentLanguage(LanguageTypeBL.GetLanguageTypeByLanguageName(LanguageTypeBL.LanguageTypes.Danish)); break; case "NL": SessionManager.SetCurrentLanguage(LanguageTypeBL.GetLanguageTypeByLanguageName(LanguageTypeBL.LanguageTypes.Neerland)); break; } } //Login model var model = new LoginModel(); if (TempData.ContainsKey(LoginPageParameters.ReturnUrl)) model.ReturnUrl = TempData[LoginPageParameters.ReturnUrl].ToString(); return View("Login", model); } }
public ActionResult Login(LoginModel model) { var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Login"); Data.Model.User user; string rawUrl = Request.RawUrl; string extranetType = ConfigurationManager.ExtranetType.ToString(); string extranetHostCode = ConfigurationManager.ExtranetHostCode.ToString(); if (ModelState.IsValid) { if (UserBL.Authenticate(model.Email, model.Password, extranetType, out user)) { #region Mise en session HostCode SessionManager.SetHostCodeSession(extranetHostCode); #endregion #region Gestion affichage popup // On autorise à afficher le popup relance Administrateur( qui permet d'afficher une popup informant que certains champs de la table FirmInstitution sont vides) Upsilab.Business.Utility.SessionManager.Set(UserBL.RelanceAdministratorSessionKey, "SHOW"); // suite dans le fichier _Layout.cshtml #region Lorsqu'un même login est utilisé pour plusieurs clients (suite dans _Layout.chtml) Upsilab.Data.Model.CustomerProspect currentCustomer = SessionManager.GetCustomerProspectSession(); if (Upsilab.Business.Utility.SessionManager.GetUserSession().IsEndUser() && currentCustomer != null && currentCustomer.CustomersUsingSameAccount != null && currentCustomer.CustomersUsingSameAccount.Count > 1) { Upsilab.Business.Utility.SessionManager.Set<bool>(UserBL.UserWithSameLoginMailSessionKey, true); } #endregion #endregion #region Enregistrement choix de langue //TODO //user.PreferredLanguage = SessionManager.GetCurrentLanguage().LanguageTypeName; //UserBL.UpdateUser(user); #endregion if (model.ReturnUrl != null) { if (Url.IsLocalUrl(model.ReturnUrl) && model.ReturnUrl.Length > 1 && model.ReturnUrl.StartsWith("/") && !model.ReturnUrl.StartsWith("//") && !model.ReturnUrl.StartsWith("/\\")) { if (Request.QueryString.Keys.Count > 0) { var redirect = new System.Web.Routing.RouteValueDictionary(); foreach (String key in Request.QueryString.Keys) { redirect.Add(key, Request.QueryString[key]); } return RedirectToAction(model.ReturnUrl, redirect); } return Redirect(model.ReturnUrl); } } if (!string.IsNullOrEmpty(model.EndUserEmailFromCRM)) //TODO { Upsilab.Data.Model.CustomerProspect customerProspect = Upsilab.Business.CustomerProspect.CustomerProspectBL.GetCustomerProspectByEmail(model.EndUserEmailFromCRM, SessionManager.GetFirmInstitutionSession().idFirmInstitution); if (customerProspect != null) { return RedirectToAction("Index", "Client", new { id = customerProspect.idCustomer }); } else { return RedirectToAction("Dashboard", "Home"); } } else { if (user.IsProviderAccess()){ if (!user.HasLABLicense() && !user.HasReportLicense()) { return RedirectToAction("Index", "FrDossier"); } } return RedirectToAction("Dashboard", "Home"); } } else { if (user != null) { if (user.IsDeleted) { ModelState.AddModelError("", LanguageData.GetContent("Login_Error_IsDeleted")); } else if (!user.IsActive) { ModelState.AddModelError("", LanguageData.GetContent("Login_Error_IsNotActive")); } } else ModelState.AddModelError("", LanguageData.GetContent("Login_ErrorMessage")); } } else { ModelState.AddModelError("", LanguageData.GetContent("Login_ErrorMessage")); } return View("Login", model); }
/// <summary> /// Do the authentification to the extranet user. Post the Email and password to its url login /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult RedirectToSite(string siteName) { string baseUrl = Upsilab.Business.Utility.UrlHelper.GetHost(); string extranetLoginUrl = string.Format("{0}/{1}/User/Login", baseUrl, siteName); try { Upsilab.Data.Model.User user = SessionManager.GetUserSession(); if (user != null) { LoginModel loginModel = new LoginModel() { Email = user.UserLogin, Password = user.UserPassword, //NB : it's an encrypted password ExtranetLoginUrl = extranetLoginUrl }; UserBL.Logout(); // Logout authentified User return View(loginModel); } return View(new LoginModel()); } catch { } return View(new LoginModel()); }
public ActionResult LoginSimulation(LoginModel model) { var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Login"); Data.Model.User user; String ipAddress = Request.UserHostAddress; string extranetType = ConfigurationManager.ExtranetType.ToString(); if (ModelState.IsValid) { if (UserBL.Authenticate(model.Email, model.Password, extranetType, out user)) { #region Gestion affichage popup // On autorise à afficher le popup relance Administrateur( qui permet d'afficher une popup informant que certains champs de la table FirmInstitution sont vides) Upsilab.Business.Utility.SessionManager.Set(UserBL.RelanceAdministratorSessionKey, "SHOW"); // suite dans le fichier _Layout.cshtml #region Lorsqu'un même login est utilisé pour plusieurs clients (suite dans _Layout.chtml) Upsilab.Data.Model.CustomerProspect currentCustomer = SessionManager.GetCustomerProspectSession(); if (Upsilab.Business.Utility.SessionManager.GetUserSession().IsEndUser() && currentCustomer != null && currentCustomer.CustomersUsingSameAccount != null && currentCustomer.CustomersUsingSameAccount.Count > 1) { Upsilab.Business.Utility.SessionManager.Set<bool>(UserBL.UserWithSameLoginMailSessionKey, true); } #endregion #endregion if (model.ReturnUrl != null) { if (Url.IsLocalUrl(model.ReturnUrl) && model.ReturnUrl.Length > 1 && model.ReturnUrl.StartsWith("/") && !model.ReturnUrl.StartsWith("//") && !model.ReturnUrl.StartsWith("/\\")) { if (Request.QueryString.Keys.Count > 0) { var redirect = new System.Web.Routing.RouteValueDictionary(); foreach (String key in Request.QueryString.Keys) { redirect.Add(key, Request.QueryString[key]); } return RedirectToAction(model.ReturnUrl, redirect); } return Redirect(model.ReturnUrl); } } //if (Repository.userIsAdmin(model.emailUtilisateur)) // return RedirectToAction("Index", "Client"); //else return RedirectToAction("Dashboard", "Home"); } else { ModelState.AddModelError("", LanguageData.GetContent("Login_ErrorMessage")); } } else { ModelState.AddModelError("", LanguageData.GetContent("Login_ErrorMessage")); } return View("Login", model); }
private LoginModel GetLoggedUser(string email, string password) { LoginModel model = new LoginModel(); model.Email = email; model.Password = password; model.ReturnUrl = "/Home/Dashboard"; return model; }