public async Task<LoginResponseDto> LoginUser(LoginRequestDto dto) { UserAuthenticationDto auth = await _userRepository.GetUserAuthentication(dto.EmailAddress); if (auth == null) { return new LoginResponseDto() { IsSuccess = false }; } bool credentialsValid = _passwordHasher.PasswordMatches(dto.Password, auth.PasswordSalt, auth.PasswordHash); if (!credentialsValid) { return new LoginResponseDto() { IsSuccess = false }; } else { var response = await _userRepository.LoginUser(auth.UserId, dto.IpAddress); return response; } }
public async Task<ActionResult> Login(LoginModel model) { if (ModelState.IsValid) { try { var loginRequest = new LoginRequestDto() { EmailAddress = model.EmailAddress, Password = model.Password, IpAddress = _httpContextHelper.GetVisitorIpAddress(), IsLandlord = true }; var response = await _landlordService.LoginUser(loginRequest); if (response.IsSuccess) { _sessionHelper.SetSessionTicketCookie(response.Session.SessionId); return RedirectToAction("Index", "Property"); } ModelState.AddModelError("", "Invalid Credentials"); } catch (Exception) { ModelState.AddModelError("", "Invalid Credentials"); throw; } } return View(model); }
public async Task<LoginResponseDto> LoginUser(LoginRequestDto dto) { var profileData = await _userManager.LoginUser(dto); return profileData; }