public async Task<IHttpActionResult> RegisterExternal(RegisterExternalBindingModel model) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } var info = await this.Authentication.GetExternalLoginInfoAsync(); if (info == null) { return this.InternalServerError(); } var user = new ApplicationUser() { UserName = model.Email, Email = model.Email }; IdentityResult result = await this.UserManager.CreateAsync(user); if (!result.Succeeded) { return this.GetErrorResult(result); } result = await this.UserManager.AddLoginAsync(user.Id, info.Login); if (!result.Succeeded) { return this.GetErrorResult(result); } return this.Ok(); }
public async Task<IHttpActionResult> Register(RegisterBindingModel model) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } var user = new ApplicationUser() { UserName = model.Email, Email = model.Email }; IdentityResult result = await this.UserManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return this.GetErrorResult(result); } return this.Ok(); }