Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // POST api/Account/Register
- [AllowAnonymous]
- [Route("Register")]
- public async Task<IHttpActionResult> Register(RegisterBindingModel model)
- {
- if (!ModelState.IsValid)
- {
- return BadRequest(ModelState);
- }
- var user = new User() { UserName = model.Email, Email = model.Email, ProfileType = (ProfileType)Enum.Parse(typeof(ProfileType), model.ProfileType) };
- IdentityResult result = await UserManager.CreateAsync(user, model.Password);
- if (!result.Succeeded)
- {
- return GetErrorResult(result);
- }
- else
- {
- UserManager.AddToRole(user.Id, "User");
- }
- return Ok();
- }
Add Comment
Please, Sign In to add comment