public async Task <IActionResult> Login([FromBody] Client.UserLogin loginInfo, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (loginInfo == null) { var error = ErrorResponsesService.BodyIsMissing(nameof(loginInfo)); return(BadRequest(error)); } var result = await signInManager.PasswordSignInAsync(loginInfo.Username, loginInfo.Password, loginInfo.RememberMe, false); if (!result.Succeeded) { var error = ErrorResponsesService.InvalidCredentialsError(nameof(loginInfo)); return(BadRequest(error)); } return(Ok(result)); }
public static Model.UserLogin Convert(Client.UserLogin clientUserLogin) { if (clientUserLogin == null) { throw new ArgumentNullException(nameof(clientUserLogin)); } if (string.IsNullOrEmpty(clientUserLogin.UserName)) { throw new ArgumentException(nameof(clientUserLogin.UserName)); } if (string.IsNullOrEmpty(clientUserLogin.Password)) { throw new ArgumentException(nameof(clientUserLogin.Password)); } var modelUserLogin = new Model.UserLogin (clientUserLogin.UserName, clientUserLogin.Password, clientUserLogin.RememberMe); return(modelUserLogin); }