1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/data/users/shared.py
Kenny Lee Sin Cheong 5f63b3a7bb chore: drop deprecated tables and remove unused code (PROJQUAY-522) (#2089)
* chore: drop deprecated tables and remove unused code

* isort imports

* migration: check for table existence before drop
2023-08-25 12:17:24 -04:00

32 lines
986 B
Python

# -*- coding: utf-8 -*-
import tldextract
import features
from data import model
def can_create_user(email_address, blacklisted_domains=None):
"""
Returns true if a user with the specified e-mail address can be created.
"""
if features.BLACKLISTED_EMAILS and email_address and "@" in email_address:
blacklisted_domains = blacklisted_domains or []
_, email_domain = email_address.split("@", 1)
extracted = tldextract.extract(email_domain)
if extracted.registered_domain.lower() in blacklisted_domains:
return False
if not features.USER_CREATION:
return False
if features.INVITE_ONLY_USER_CREATION:
if not email_address:
return False
# Check to see that there is an invite for the e-mail address.
return bool(model.team.lookup_team_invites_by_email(email_address))
# Otherwise the user can be created (assuming it doesn't already exist, of course)
return True