public async Task <IActionResult> OnPostAsync(string refCode, string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { if (!Helpers.ReCaptchaPassed(Request.Form["g-recaptcha-response"], ConfigurationManager.AppSetting["GoogleReCaptcha:secret"].ToString(), _logger)) { TempData["ERROR"] = "You failed the CAPTCHA, please try again."; return(Redirect("/Identity/Account/Register")); } var user = new ApplicationUser { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { string paymentId = TRTLService.GetPaymentId(); user.TRTLPaymentId = paymentId; if (refCode != null && refCode.Length > 0) { user.RefCodeUsed = refCode; } await _userManager.UpdateAsync(user); _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); //await _signInManager.SignInAsync(user, isPersistent: false); TempData["Message"] = "Please confirm your email"; return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { TempData["ERROR"] = error.Description; ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Redirect("/Identity/Account/Register")); //return Page(); }
public async Task <IActionResult> Index() { HomeModel model = new HomeModel(); ApplicationUser user = await _userManager.GetUserAsync(User); if (user != null) { model.OwnedAnimals = _db.UserAnimals.Where(ua => ua.UserId == user.Id).Include(ua => ua.Animal).ToList(); string paymentid = TRTLService.GetPaymentId(); } return(View(model)); }
public async Task <IActionResult> OnGetAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } var userName = await _userManager.GetUserNameAsync(user); var email = await _userManager.GetEmailAsync(user); var phoneNumber = await _userManager.GetPhoneNumberAsync(user); var TRTLPaymentIdExisting = user.TRTLPaymentId; if (TRTLPaymentIdExisting != null && TRTLPaymentIdExisting.Length > 0) { TRTLPaymentId = TRTLPaymentIdExisting; } else { TRTLPaymentIdExisting = TRTLService.GetPaymentId(); user.TRTLPaymentId = TRTLPaymentIdExisting; TRTLPaymentId = TRTLPaymentIdExisting; await _userManager.UpdateAsync(user); } Username = userName; if (_db.AdminModel.Count() > 0) { TRTLAddress = _db.AdminModel.FirstOrDefault().PaymentAddress; } else { TRTLAddress = "Please contact administrator"; } return(Page()); }