/// <summary> /// method that will create a new user account. /// </summary> /// <param name="ModelUser"></param> /// <returns></returns> public async Task<IdentityResult> RegisterUser(ModelUser ModelUser) { //instantiate IdentityUser object //assign the new username IdentityUser user = new IdentityUser { UserName = ModelUser.UserName }; //Create a new user //it will automatically hash the password var result = await _userManager.CreateAsync(user, ModelUser.Password); return result; }
public async Task<IHttpActionResult> Register(ModelUser userModel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } IdentityResult result = await _repo.RegisterUser(userModel); IHttpActionResult errorResult = GetErrorResult(result); if (errorResult != null) { return errorResult; } return Ok(); }