From 9335b18d16e56ad38b604e0279e09f33c0b8d988 Mon Sep 17 00:00:00 2001 From: Aubrey Date: Fri, 27 Mar 2020 11:20:36 -0400 Subject: [PATCH] Check for a valid email. --- .../Modules/Admin/Register/Index.razor | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Oqtane.Client/Modules/Admin/Register/Index.razor b/Oqtane.Client/Modules/Admin/Register/Index.razor index 46fdca01..a3624623 100644 --- a/Oqtane.Client/Modules/Admin/Register/Index.razor +++ b/Oqtane.Client/Modules/Admin/Register/Index.razor @@ -1,4 +1,5 @@ @namespace Oqtane.Modules.Admin.Register +@using System.Text.RegularExpressions; @inherits ModuleBase @inject NavigationManager NavigationManager @inject IUserService UserService @@ -42,13 +43,15 @@ string _confirm = ""; string _email = ""; string _displayName = ""; + bool _isEmailValid = false; private async Task Register() { try { _message = ""; - if (_username != "" && _password != "" && _confirm != "" && _email != "") + IsValidEmail(); + if (_username != "" && _password != "" && _confirm != "" && _isEmailValid) { if (_password == _confirm) { @@ -94,4 +97,16 @@ { NavigationManager.NavigateTo(NavigateUrl("")); } +} + private void IsValidEmail() + { + if (_email != ""){ + _isEmailValid = true; + } + + _isEmailValid = Regex.IsMatch(_email, + @"^(?("")("".+?(?