Skip to content

Commit

Permalink
Tone down the AccountEntity.email format validation to require one AT…
Browse files Browse the repository at this point in the history
… sign

    An RFC complient email address can be very complex so rely on later
    email verification handshake to really checkout that email is a good format.
Closes #63
  • Loading branch information
Misterblue committed Nov 7, 2020
1 parent 0511c01 commit 8dca923
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Entities/AccountEntity.ts
Expand Up @@ -149,7 +149,10 @@ export const accountFields: { [key: string]: FieldDefn } = {
let validity: ValidateResponse;
if (typeof(pVal) === 'string') {
// Check email for sanity
if (/^[A-Za-z0-9+\-_\.]+@[A-Za-z0-9-\.]+$/.test(pVal)) {
// Old style check which doesn't cover all the RFC complient email addresses possible
// if (/^[A-Za-z0-9+\-_\.]+@[A-Za-z0-9-\.]+$/.test(pVal)) {
// Much simpiler check that just makes sure there is one AT sign
if ((pVal.match(/@/g) || []).length === 1) {
// Make sure no other account is using this email address
const otherAccount = await Accounts.getAccountWithEmail(pVal);
if (IsNullOrEmpty(otherAccount) || otherAccount.id === (pEntity as AccountEntity).id) {
Expand All @@ -160,7 +163,7 @@ export const accountFields: { [key: string]: FieldDefn } = {
};
}
else {
validity = { valid: false, reason: 'username can contain only A-Za-z0-9+-_.' };
validity = { valid: false, reason: 'email address needs one AT sign' };
};
}
else {
Expand Down

0 comments on commit 8dca923

Please sign in to comment.