---
# System prepended metadata

title: 'Restriction on Gmail Email address to avoid persisting duplicate email with a combination of "." and/or "-" '

---


# Restriction on persisting of duplicate google email
**Note**: The general format of an email address is 
**local-part@domain**

# Problem Statement


Duplicate email is getting created in GR when user is trying to register with same email with a combination of **"dot" and/or "-"**.This issue is happening for Google email id as google ignores "-" or "." in the **"local-part"**  part of the email id.

## Example:

Google treats the following emails as same

* abc.d@gmail.com
* a.b.c.d@gmail.com
* a-b-c-d@gmail.com
* abcd@gmail.com 

But in Tatadigital the above mentioned emails are treated as different email.

As per the current construct  customer can have multiple such emails in tatadigital which are connected to one gmail id.




# Solution


We can implement a regex which will provide an extra layer of validation for any google email id given by user.
**This regex will remove any "." or "-" from the "local-part"  of the email id.**

We can use the following regex 

**\.(?=[^\s@]*@[^\s@.]+\.[^\s@.])
\-(?=[^\s@]*@[^\s@-]+\.[^\s@-])
\[\.\-](?=[^\s@]*@[^\s@.]+\.[^\s@.])**


# Steps to follow for any new email

1. During login with email id or update of an email id,user input email  has to go through the extra layer of validation to eliminate "." or "-" from "local-part" of the email.
2. For example in step 1 if user gives **a.b.c-d@gmail.com** , after it passes through the validation layer it will become **abcd@gmail.com**. In GR the email will be stored as **a.b.c-d@gmail.com** in primaryEmailId field and store **adcd@gmail.com** in lookup




## Changes required in GR and SSO to implement this solution
* GR will have an extra layer of validation in ,check-gr,Update-profile","update-email","claim-email" journey.
* In any of the cases where sso directly queries lookup with email id, sso needs to pass through the eamil id in the regular expression before calling gr lookup.
* SSO needs to consume the email id from GR after final update in GR DB.
* Use case where "login with email id" is possible, after user inputs the email, the same regex validation needs to be incorporated at the source end.
