public async Task<IHttpActionResult> RegisterExternal(RegisterExternalBindingModel model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var info = await Authentication.GetExternalLoginInfoAsync(); if (info == null) { return InternalServerError(); } var user = new ApplicationUser() { UserName = model.Email, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user); if (!result.Succeeded) { return GetErrorResult(result); } result = await UserManager.AddLoginAsync(user.Id, info.Login); if (!result.Succeeded) { return GetErrorResult(result); } return Ok(); }
public async Task<IHttpActionResult> Register(RegisterBindingModel model) { if (!ModelState.IsValid) { return BadRequest(ModelState); } // added new properties for user: FirstName and LastName var user = new ApplicationUser() { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName }; // *********** MAP LOCATION SEED DATA PER USER **************// // All new users are given this list of seed locations to avoid an empty map demo. // We can discontinue or modify this behavior at any time below. user.Locations = new List<PlanLocation> { new PlanLocation() { Title = "Coder Camps!", Latitude = 47.66973856375987, Longitude = -122.11834843200688, LocationType = PlanLocationType.CoderCamps }, new PlanLocation() { Title = "Bugout #1", Latitude = 48.372127563769325, Longitude = -117.92478568270114, LocationType = PlanLocationType.Bugout }, new PlanLocation() { Title = "Weapons #1", Latitude = 47.76386240369889, Longitude = -117.91522092535403, LocationType = PlanLocationType.Weapons }, new PlanLocation() { Title = "Food #1", Latitude = 47.136182663368174, Longitude = -117.8995997400513, LocationType = PlanLocationType.Food }, new PlanLocation() { Title = "Bugout #2", Latitude = 48.372127563769325, Longitude = -117.92478568270114, LocationType = PlanLocationType.Bugout }, new PlanLocation() { Title = "Weapons #2", Latitude = 47.76386240369889, Longitude = -117.91522092535403, LocationType = PlanLocationType.Weapons }, new PlanLocation() { Title = "Food #2", Latitude = 47.136182663368174, Longitude = -117.8995997400513, LocationType = PlanLocationType.Food }, new PlanLocation() { Title = "Bugout #3", Latitude = 48.372127563769325, Longitude = -117.92478568270114, LocationType = PlanLocationType.Bugout }, new PlanLocation() { Title = "Weapons #3", Latitude = 47.76386240369889, Longitude = -117.91522092535403, LocationType = PlanLocationType.Weapons }, new PlanLocation() { Title = "Food #3", Latitude = 47.136182663368174, Longitude = -117.8995997400513, LocationType = PlanLocationType.Food }, new PlanLocation() { Title = "Bugout #4", Latitude = 47.136182663368174, Longitude = -117.8995997400513, LocationType = PlanLocationType.Bugout }, new PlanLocation() { Title = "Weapons #4", Latitude = 48.86575367028046, Longitude = -125.30355341150668, LocationType = PlanLocationType.Weapons }, new PlanLocation() { Title = "Food #4", Latitude = 49.248605954881185, Longitude = -125.2869317622414, LocationType = PlanLocationType.Food } }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return GetErrorResult(result); } return Ok(); }