-
Notifications
You must be signed in to change notification settings - Fork 56
Implement dot notation email validation for gmail #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement dot notation email validation for gmail #302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfikria there is one moment I'd like to explain more here.
When we invite user by email we first don't know if a user with such email is already registered at Topcoder or no. For users who already registered on Topcoder we would create an invitation record which would include not only email, but also userId
. For users who are not yet registered on Topcoder, we would create invitation record only with an email.
Here is how the code works.
First, we are looking in the system if a user with usch email is already registered in this line https://github.com/topcoder-platform/tc-project-service/blob/feature/fix-email-duplicated-invites/src/routes/projectMemberInvites/create.js#L59
And after we filter emails which we are inviting into two groups: emails which belong to users which already registered on Topcoder: https://github.com/topcoder-platform/tc-project-service/blob/feature/fix-email-duplicated-invites/src/routes/projectMemberInvites/create.js#L62-L68 and users who are not yet registered on Topcoder https://github.com/topcoder-platform/tc-project-service/blob/feature/fix-email-duplicated-invites/src/routes/projectMemberInvites/create.js#L70-L72
For users who are already registered, we are creating invites using their userId
and email
instead of only their emails, here https://github.com/topcoder-platform/tc-project-service/blob/feature/fix-email-duplicated-invites/src/routes/projectMemberInvites/create.js#L76-L83
For users who are not registered yet, we are creating invitation record sonly with email, which is done on these lines: https://github.com/topcoder-platform/tc-project-service/blob/feature/fix-email-duplicated-invites/src/routes/projectMemberInvites/create.js#L88-L94
So there are two separate logics when we filter emails.
-
In these lines https://github.com/topcoder-platform/tc-project-service/blob/feature/fix-email-duplicated-invites/src/routes/projectMemberInvites/create.js#L70-L72 we are filter emails which we are inviting for users who are not yet registered on Tocpcoder. And here we should apply the same logic: compare emails case-insensitive. Gmail emails should be still treated different event if the difference is dot "." here.
-
In these lines https://github.com/topcoder-platform/tc-project-service/blob/feature/fix-email-duplicated-invites/src/routes/projectMemberInvites/create.js#L70-L72 we are doing another thing.
When we already have a list of emailsnonExistentUserEmails
of users who is not yet registered on Topcoder we should check if they alrady have invitaion record or no. And we would create an invitation for the users who are not yet registered only if they do not yet have invitation record.
For this case, you've already implemented the fix to ignore letter case, and also now implementing ignoring differences in Gmail emails.
So there are two places which filter emails in different arrays for different reasons. In the latest changed these two places are merged into one, but the logic to filter unregistered users is lost now. So invitations which we put in the code to invitePromises
would be duplicated for existent users. I know that code may be confusing here.
Please, let me know if the details from above help or there are any concerns.
@maxceem i've update the PR. Please review it again thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for a quick update @mfikria
Looks good. But so far emails like WITHOUT-dot@gmail.com
, and WITHadot@gmail.com
also treated the same. So we can add any characters in between letters.
[recommended]
It would be nice if compareEmail
would be a pure function and doesn't depend on the global config
variable. I mean if it gets all the data from the arguments only.
@mfikria I've also noticed that email with domains like this: Also, we don't have to disable eslint for the line:
I think the resason for eslint error is that we don't have to escape |
@maxceem updated with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mfikria.
Email like WITHOUTadot@gmail.com
(with a
) is still treated the same as WITHOUTdot@gmail.com
(without a
).
Also, current regexp treats domains like gmail.fake.com
as Gmail domains and also tries to apply the same Gmail rules. I've googled a bit, and looks like Gmail can only have two domains:
gmail.com
googlemail.com
So we should only apply these rules for emails in these two domains.
Noticed one more thing:
The reason for this is that the method
|
@maxceem i've updated the function:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works good now.
Thanks, @mfikria.
5d29438
into
topcoder-platform:feature/fix-email-duplicated-invites
No description provided.