Currently, I am facing a scenario, where I should differentiate whether a given user belongs to a Gmail account or a G Suite account.
I have the email id of the user. As of now, the only visible difference is that the email address has a different domain name for a G Suite account. For an normal Gmail account the domain name is "gmail.com".
I don't feel safe to rely on this. What is the recommended way to identify the account type of an user?
Thanks in advance.
This is safe to rely on, and many users have already used this technique successfully. Emails addresses contain only one "@" sign, so in order to verify this you could use a simple function such as:
function isGSuite(email) {
return email.split("@")[1] != 'gmail.com';
}
In fact, there is no API or any other method you can use to check whether the account is actually a GSuite account. Given an e-mail address that is not gmail
, there is no public way of determining whether it is part of a GSuite domain, since that could present security and privacy issues.