MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / _mask_email

Function _mask_email

web/pgadmin/authenticate/mfa/email.py:102–130  ·  view source on GitHub ↗

Args: _email (str): Email address to be masked Returns: str: Masked email address

(_email: str)

Source from the content-addressed store, hash-verified

100
101
102def _mask_email(_email: str) -> str:
103 """
104
105 Args:
106 _email (str): Email address to be masked
107
108 Returns:
109 str: Masked email address
110 """
111 import re
112 email_split = re.split('@', _email)
113 username, domain = email_split
114 domain_front, *domain_back_list = re.split('[.]', domain)
115 users = re.split('[.]', username)
116
117 def _mask_except_first_char(_str: str) -> str:
118 """
119 Mask all characters except first character of the input string.
120 Args:
121 _str (str): Input string to be masked
122
123 Returns:
124 str: Masked string
125 """
126 return _str[0] + '*' * (len(_str) - 1)
127
128 return '.'.join([_mask_except_first_char(user) for user in users]) + \
129 '@' + _mask_except_first_char(domain_front) + '.' + \
130 '.'.join(domain_back_list)
131
132
133def send_email_code() -> Response:

Callers 1

_send_code_to_emailFunction · 0.85

Calls 2

_mask_except_first_charFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected