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); } var user = new ApplicationUser() { UserName = model.Email, Email = model.Email, IsDeleted = model.IsDeleted }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); #region SendWelcomeEmail var welcomeEmail = new SendGridMessage(); welcomeEmail.From = new MailAddress("*****@*****.**"); string recipients = user.Email; welcomeEmail.AddTo(recipients); welcomeEmail.Subject = "Welcome To TurnHere"; welcomeEmail.Html = File.ReadAllText(HttpContext.Current.Server.MapPath("~/App_Data/Templates/WelcomeEmail.txt")); welcomeEmail.Text = "Hello World plain text!"; var credentials = new NetworkCredential("cadeawinter", "TeamBartindr69"); var transportWeb = new Web("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"); // Send the email. transportWeb.DeliverAsync(welcomeEmail); #endregion if (!result.Succeeded) { return GetErrorResult(result); } return Ok(); }