Skip to content

Commit 31e0a6f

Browse files
author
alirizaadiyahsi
authored
Merge pull request #319 from acjh/patch-24
Add plus sign and apostrophe to email pattern
2 parents 5889f32 + 62df82d commit 31e0a6f

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

angular/src/account/register/register.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h4 class="text-center">{{l("Register")}}</h4>
1919

2020
<div class="form-group form-float">
2121
<div class="form-line">
22-
<input materialInput class="form-control" type="email" [(ngModel)]="model.emailAddress" name="EmailAddress" required maxlength="255" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,})+$" />
22+
<input materialInput class="form-control" type="email" [(ngModel)]="model.emailAddress" name="EmailAddress" required maxlength="255" pattern="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" />
2323
<label class="form-label">{{l('EmailAddress')}}</label>
2424
</div>
2525
</div>

angular/src/app/tenants/create-tenant/create-tenant.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h4 class="modal-title">
3535
</div>
3636
<div class="form-group form-float">
3737
<div class="form-line">
38-
<input type="email" name="AdminEmailAddress" class="form-control" [(ngModel)]="tenant.adminEmailAddress" required maxlength="256" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,})+$">
38+
<input type="email" name="AdminEmailAddress" class="form-control" [(ngModel)]="tenant.adminEmailAddress" required maxlength="256" pattern="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$">
3939
<label class="form-label">{{l("AdminEmailAddress")}}</label>
4040
</div>
4141
</div>

angular/src/app/users/create-user/create-user.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h4 class="modal-title">
5555
<div class="col-sm-12">
5656
<div class="form-group form-float">
5757
<div class="form-line">
58-
<input id="email" type="email" name="EmailAddress" [(ngModel)]="user.emailAddress" maxlength="256" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,})+$" class="validate form-control">
58+
<input id="email" type="email" name="EmailAddress" [(ngModel)]="user.emailAddress" maxlength="256" pattern="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" class="validate form-control">
5959
<label for="email" class="form-label">{{l("EmailAddress")}}</label>
6060
</div>
6161
</div>

angular/src/app/users/edit-user/edit-user.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ <h4 class="modal-title">
5353
<div class="col-sm-12">
5454
<div class="form-group form-float">
5555
<div class="form-line">
56-
<input id="email" type="email" name="EmailAddress" [(ngModel)]="user.emailAddress" maxlength="256" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,})+$" class="validate form-control">
56+
<input id="email" type="email" name="EmailAddress" [(ngModel)]="user.emailAddress" maxlength="256" pattern="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" class="validate form-control">
5757
<label for="email" class="form-label">{{l("EmailAddress")}}</label>
5858
</div>
5959
</div>
@@ -99,4 +99,4 @@ <h4 class="modal-title">
9999
</form>
100100
</div>
101101
</div>
102-
</div>
102+
</div>

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Models/Account/RegisterViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System.Collections.Generic;
22
using System.ComponentModel.DataAnnotations;
3-
using System.Text.RegularExpressions;
43
using Abp.Auditing;
54
using Abp.Authorization.Users;
65
using Abp.Extensions;
6+
using AbpCompanyName.AbpProjectName.Validation;
77

88
namespace AbpCompanyName.AbpProjectName.Web.Models.Account
99
{
@@ -37,8 +37,7 @@ public IEnumerable<ValidationResult> Validate(ValidationContext validationContex
3737
{
3838
if (!UserName.IsNullOrEmpty())
3939
{
40-
var emailRegex = new Regex(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
41-
if (!UserName.Equals(EmailAddress) && emailRegex.IsMatch(UserName))
40+
if (!UserName.Equals(EmailAddress) && ValidationHelper.IsEmail(UserName))
4241
{
4342
yield return new ValidationResult("Username cannot be an email address unless it's the same as your email address!");
4443
}

0 commit comments

Comments
 (0)