Check for a valid email.
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
@namespace Oqtane.Modules.Admin.Register
|
@namespace Oqtane.Modules.Admin.Register
|
||||||
|
@using System.Text.RegularExpressions;
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
@ -42,13 +43,15 @@
|
|||||||
string _confirm = "";
|
string _confirm = "";
|
||||||
string _email = "";
|
string _email = "";
|
||||||
string _displayName = "";
|
string _displayName = "";
|
||||||
|
bool _isEmailValid = false;
|
||||||
|
|
||||||
private async Task Register()
|
private async Task Register()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_message = "";
|
_message = "";
|
||||||
if (_username != "" && _password != "" && _confirm != "" && _email != "")
|
IsValidEmail();
|
||||||
|
if (_username != "" && _password != "" && _confirm != "" && _isEmailValid)
|
||||||
{
|
{
|
||||||
if (_password == _confirm)
|
if (_password == _confirm)
|
||||||
{
|
{
|
||||||
@ -94,4 +97,16 @@
|
|||||||
{
|
{
|
||||||
NavigationManager.NavigateTo(NavigateUrl(""));
|
NavigationManager.NavigateTo(NavigateUrl(""));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
private void IsValidEmail()
|
||||||
|
{
|
||||||
|
if (_email != ""){
|
||||||
|
_isEmailValid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isEmailValid = Regex.IsMatch(_email,
|
||||||
|
@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
|
||||||
|
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
|
||||||
|
RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user