public async Task <IActionResult> OnPostConfirmationAsync(string returnUrl = null) { returnUrl ??= Url.Content("~/"); // Get the information about the user from the external login provider ExternalLoginInfo info = await _signInManager.GetExternalLoginInfoAsync(); if (info == null) { ErrorMessage = "Error loading external login information during confirmation."; return(RedirectToPage("./Login", new { ReturnUrl = returnUrl })); } if (ModelState.IsValid) { Rocks r = new Rocks(_configuration); V v = new V(_configuration); RocksUser ru = r.GetAgentName(info.ProviderKey); VUser vu = v.GetAgentName(info.ProviderKey); string agentName = string.Empty; bool blocked = false; if (ru != null) { if (ru.Smurf) { ModelState.AddModelError("ErrorMessage", "Sorry, smurfed on rocks"); blocked = true; } else { agentName = ru.AgentName; } } if (vu != null) { if (vu.Blacklisted || vu.Quarantine || vu.Flagged) { ModelState.AddModelError("ErrorMessage", "Sorry, smurfed on V"); blocked = true; } else { agentName = vu.AgentName; } } if (string.IsNullOrWhiteSpace(agentName) || blocked) { WhitelistItem wli = _context.Whitelist.FirstOrDefault(x => x.GoogleId == info.ProviderKey); if (wli == null) { ModelState.AddModelError("ErrorMessage", "Sorry, you are not know, ask the Telegram chat to get whitelisted"); ProviderDisplayName = info.ProviderDisplayName; ReturnUrl = returnUrl; return(Page()); } agentName = wli.AgentName; } ApplicationUser user = new ApplicationUser { UserName = agentName, Email = Input.Email, EmailConfirmed = true }; IdentityResult result = await _userManager.CreateAsync(user); if (result.Succeeded) { result = await _userManager.AddLoginAsync(user, info); if (result.Succeeded) { _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider); string userId = await _userManager.GetUserIdAsync(user); string code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); string callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = userId, 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>."); // If account confirmation is required, we need to show the link if we don't have a real email sender if (_userManager.Options.SignIn.RequireConfirmedAccount) { return(RedirectToPage("./RegisterConfirmation", new { Email = Input.Email })); } await _signInManager.SignInAsync(user, isPersistent : false, info.LoginProvider); return(LocalRedirect(returnUrl)); } } foreach (IdentityError error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } ProviderDisplayName = info.ProviderDisplayName; ReturnUrl = returnUrl; return(Page()); }