public async Task CanRegisterUser() { var model = new RegisterBindingModel { Email = this.testLogin, Password = TEST_PASSWORD, ConfirmPassword = TEST_PASSWORD }; uri = URI_BASE + "/Register"; var response = await PostAsync(model); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); uri = URI_BASE + "/UserInfo"; response = await GetAsync(); Assert.AreEqual(HttpStatusCode.Unauthorized, response.StatusCode); uri = "/Token"; response = await PostAsync(new LoginViewModel { Password = TEST_PASSWORD, UserName = testLogin }); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); }
public async Task<IHttpActionResult> Register(RegisterBindingModel model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var user = new User { UserName = model.Email, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return GetErrorResult(result); } return Ok(); }