public static String LoginBootStrap() { LoginViewData view = new LoginViewData(); view.RedirectUrl = FormsAuthentication.GetRedirectUrl(String.Empty, true); return(PageViewHelper.LoadPage("/LoginBootStrap.aspx", view)); }
public ActionResult Login(string returnUrl) { var loginUser = new LoginViewData(); try { if (TryUpdateModel(loginUser) && ValidateModel(loginUser)) { User user = this._authenticationService.AuthenticateUser(loginUser.Username, loginUser.Password, Request.UserHostAddress); FormsAuthentication.SetAuthCookie(user.Id.ToString(), false); if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } return RedirectToAction("Index", "Dashboard"); } } catch (AuthenticationException ex) { Logger.WarnFormat("User {0} unsuccesfully logged in with password {1}.", loginUser.Username, loginUser.Password); Messages.AddException(ex); } catch (Exception ex) { Logger.Error("Unexpected error while logging in", ex); Messages.AddException(ex); } return View("Index", loginUser); }
public ActionResult Login(string returnUrl) { var loginUser = new LoginViewData(); try { if (TryUpdateModel(loginUser) && ValidateModel(loginUser)) { User user = this._authenticationService.AuthenticateUser(loginUser.Username, loginUser.Password, Request.UserHostAddress); FormsAuthentication.SetAuthCookie(user.Id.ToString(), false); if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("Index", "Dashboard")); } } catch (AuthenticationException ex) { Logger.WarnFormat("User {0} unsuccesfully logged in with password {1}.", loginUser.Username, loginUser.Password); Messages.AddException(ex); } catch (Exception ex) { Logger.Error("Unexpected error while logging in", ex); Messages.AddException(ex); } return(View("Index", loginUser)); }
public async Task <IActionResult> Login(LoginViewData model) { if (ModelState.IsValid) { var user = await userManager.FindByEmailAsync(model.Email); if (user != null) { var remember = model.RemeberMe; var result = await signInManager.PasswordSignInAsync(user.UserName, model.Password, remember, false); if (result.Succeeded) { if (model.ReturnUrl != null) { return(Redirect(model.ReturnUrl)); } else { return(RedirectToAction("Index", "Announcements")); } } else { ModelState.AddModelError("Login", "Błędne hasło."); } } else { ModelState.AddModelError("User", "Nie znaleziono użytkownika o podanym mailu."); } } return(View()); }
public ActionResult Login(string returnUrl) { var sawLoginUrl = FirmaWebConfiguration.SAWEndPoint; var adfsLoginUrl = FirmaWebConfiguration.ADFSEndPoint; var viewData = new LoginViewData(CurrentPerson, sawLoginUrl, adfsLoginUrl); return(RazorView <Login, LoginViewData>(viewData)); }
/// <inheritdoc /> /// <summary> /// Gathers the data needed to display the login page. /// </summary> /// <param name="electionId"> /// An integer containing the ElectionId. /// </param> /// <returns> /// A hydrated instance of the <see cref="LoginViewModel" /> class, /// within a Task. (Task<LoginViewModel>) /// </returns> public async Task <LoginViewModel> GetLoginScreenDataAsync(int electionId) { LoginViewData retrievedLoginData = await _loginScreenDataAccess.GetDataForLoginScreenAsync(electionId); var dtNow = DateTime.Now; if (dtNow >= retrievedLoginData.OpenDate && dtNow <= retrievedLoginData.CloseDate) { retrievedLoginData.VotingIsOpen = true; } // Map LoginViewData -> LoginViewModel var mapperConfig = new MapperConfiguration(cfg => { cfg.CreateMap <LoginViewData, LoginViewModel>(); }); var iMapper = mapperConfig.CreateMapper(); var loginViewModel = iMapper.Map <LoginViewData, LoginViewModel>(retrievedLoginData); return(loginViewModel); }
public async Task <ActionResult> Login(LoginViewData model, string returnUrl) { if (ModelState.IsValid) { User user = await UserManager.FindAsync(model.Item.UserName, model.Item.Password); if (user != null) { await SignInAsync(user, model.Item.RememberMe); return(RedirectToLocal(returnUrl)); } ModelState.AddModelError("", "Invalid username or password."); } // If we got this far, something failed, redisplay form return(View(model)); }