public async Task <IActionResult> LoginUser([FromBody] LoginUserParams loginUserParams) { var result = await _signInManager.PasswordSignInAsync(loginUserParams.Username, loginUserParams.Password, false, false); if (!result.Succeeded) { return(Unauthorized()); } var user = await _userManager.FindByNameAsync(loginUserParams.Username); return(Json(user)); }
public async Task <IActionResult> Login([FromBody] LoginUserParams userParams) { var user = await _userEngine.FindUserByUsername(userParams.Username); var signInResult = await _userEngine.PasswordSignInUser(user, userParams.Password); if (signInResult.Succeeded) { return(Json(signInResult)); } return(Unauthorized()); }
public static async Task <string> LoginAsync(string username, string password, string loginURI) { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; var userCredentials = new UserCredential() { Name = username, Password = password }; var loginUserParams = new LoginUserParams(); loginUserParams.UserCredential = userCredentials; var resultdeserealizedJson = await ServiceHelperExtensions.CallRestServiceAsync(Format.JSON, RestMethod.POST, "", new Uri(loginURI), loginUserParams); var resultdeserealized = JsonSerializer.DeserializeObject <LoginResult>(resultdeserealizedJson); return(resultdeserealized.AccessToken.AuthorizationHeader); }