Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. $(document).ready(function () {
  2.  
  3. var register = function() {
  4. var dataa = {
  5. Email: "password@host.com",
  6. Password: "password",
  7. ConfirmPassword: "password"
  8. };
  9.  
  10. alert("test");
  11.  
  12. $.ajax({
  13. type: 'POST',
  14. url: 'api/Account/Register',
  15. contentType: 'application/json; charset=utf-8',
  16. data: JSON.stringify(dataa)
  17. });
  18. return false;
  19. }
  20.  
  21. $('#btnRegister').click(register);
  22. });
  23.  
  24. [Authorize]
  25. [RoutePrefix("api/Account")]
  26. public class AccountController : ApiController
  27. {
  28. [AllowAnonymous]
  29. [Route("Register")]
  30. public async Task<IHttpActionResult> Register(RegisterBindingModel model)
  31. {
  32. if (!ModelState.IsValid)
  33. {
  34. return BadRequest(ModelState);
  35. }
  36.  
  37. var user = new ApplicationUser() { UserName = model.Email, Email = model.Email };
  38.  
  39. IdentityResult result = await UserManager.CreateAsync(user, model.Password);
  40.  
  41. if (!result.Succeeded)
  42. {
  43. return GetErrorResult(result);
  44. }
  45.  
  46. return Ok();
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement