public LoginWindowVmFactory(IEventAggregator ea, LoginModelViewModel loginModelVm, RegisterViewModel registerVm, IViewManager viewManager) { _ea = ea; _loginModelVm = loginModelVm; _registerVm = registerVm; _viewManager = viewManager; }
public ActionResult Login(LoginModelViewModel model) { TempData["success"] = false; if (ModelState.IsValid && string.IsNullOrWhiteSpace(model.HelperField)) { var valid = Members.Login(model.Username, model.Password); if (valid) { FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe); TempData["success"] = true; return(RedirectToUmbracoPage(model.RedirectPage)); } } return(CurrentUmbracoPage()); }
public async Task <IActionResult> Login(LoginModelViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (ModelState.IsValid) { var authenticateResult = await _sessionProvider.Authenticate(model.Email, _hashGenerator.Generate(model.Password, true)); if (authenticateResult.ResultMessage.MessageType != MessageType.Error) { var userModel = new UserModel(model.Email, _hashGenerator.Generate(model.Password, true), authenticateResult.Model.SessionId); _userManager.SetUser(userModel); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError(String.Empty, authenticateResult.ResultMessage.Message); } } return(View(model)); }
public IActionResult CreateToken([FromBody] LoginModelViewModel login) { IActionResult response = Unauthorized(); _logger.LogInformation($"Login {login.Email}"); if (String.IsNullOrWhiteSpace(login.Password)) { return(response); } var user = Authenticate(login); if (user != null) { var tokenString = BuildToken(user); response = Ok(new { Name = user.Name, Token = tokenString }); } return(response); }
private UserModel Authenticate(LoginModelViewModel login) { UserModel user = _userRepository.Login(login.Email, _userHelper.PasswordHash(login.Password)); return(user); }