From 8975f3d0b91fc3c8f373ea2a10e91b7daad527e1 Mon Sep 17 00:00:00 2001 From: krystian kempski Date: Tue, 30 Apr 2024 18:26:04 +0200 Subject: [PATCH] confirmation email --- .../Areas/Identity/Pages/Account/Register.cshtml.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/DagoniteEmpire/Areas/Identity/Pages/Account/Register.cshtml.cs b/DagoniteEmpire/Areas/Identity/Pages/Account/Register.cshtml.cs index 1ea86f6..49c37b7 100644 --- a/DagoniteEmpire/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/DagoniteEmpire/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -20,6 +20,7 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace DagoniteEmpire.Areas.Identity.Pages.Account @@ -131,6 +132,13 @@ public async Task OnPostAsync(string returnUrl = null) var user = CreateUser(); await _userStore.SetUserNameAsync(user, Input.UserName, CancellationToken.None); + var resultuser = await _userManager.FindByEmailAsync(Input.Email); + if(resultuser.UserName != null) + { + ModelState.AddModelError(string.Empty, "Email already exists"); + return Page(); + } + await _emailStore.SetEmailAsync(user, Input.Email, CancellationToken.None); var result = await _userManager.CreateAsync(user, Input.Password);