import logging

from covcov.infrastructure.db.database import Database
from covcov.infrastructure.configuration import config

logger = logging.getLogger(__name__)
db = Database("database")
#
region         = config["cognito"]["COG_REGION"]
user_pool_id   = config["cognito"]["COG_USER_POOL_ID"]
app_client_id  = config["cognito"]["COG_APP_CLIENT_ID"]

def handle(event, context):
  user_attrs =  event ['request']['userAttributes']

  # https://docs.aws.amazon.com/fr_fr/cognito/latest/developerguide/cognito-user-pool-managing-errors.html / SignUp: UsernameExistsException
  # https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-aliases
  if db.native_execute_sqls([f"select 1 from company where email = '{user_attrs ['email']}'" ])[0] != 0 :
    raise Exception(f": [Email '{user_attrs ['email']}' déjà utilisé. Merci d'en saisir un autre]")

  # event ['userName'] = urllib.parse.unquote_plus(event ['userName'])
  # if db.native_execute_sqls([f"select 1 from company where name = '{event ['userName']}'" ])[0] != 0 :
  #   raise Exception(f": [Nom d'établissement '{event ['userName']}' déjà utilisé. Merci d'en saisir un autre]")

  return event

45a0609faccc7a7f36d8bc184a2310032f9d8594
<mask token>

<mask token>


def handle(event, context):
    user_attrs = event['request']['userAttributes']
    if db.native_execute_sqls([
        f"select 1 from company where email = '{user_attrs['email']}'"])[0
        ] != 0:
        raise Exception(
            f": [Email '{user_attrs['email']}' déjà utilisé. Merci d'en saisir un autre]"
            )
    return event

<mask token>
logger = logging.getLogger(__name__)
db = Database('database')
region = config['cognito']['COG_REGION']
user_pool_id = config['cognito']['COG_USER_POOL_ID']
app_client_id = config['cognito']['COG_APP_CLIENT_ID']


def handle(event, context):
    user_attrs = event['request']['userAttributes']
    if db.native_execute_sqls([
        f"select 1 from company where email = '{user_attrs['email']}'"])[0
        ] != 0:
        raise Exception(
            f": [Email '{user_attrs['email']}' déjà utilisé. Merci d'en saisir un autre]"
            )
    return event

import logging
from covcov.infrastructure.db.database import Database
from covcov.infrastructure.configuration import config
logger = logging.getLogger(__name__)
db = Database('database')
region = config['cognito']['COG_REGION']
user_pool_id = config['cognito']['COG_USER_POOL_ID']
app_client_id = config['cognito']['COG_APP_CLIENT_ID']


def handle(event, context):
    user_attrs = event['request']['userAttributes']
    if db.native_execute_sqls([
        f"select 1 from company where email = '{user_attrs['email']}'"])[0
        ] != 0:
        raise Exception(
            f": [Email '{user_attrs['email']}' déjà utilisé. Merci d'en saisir un autre]"
            )
    return event

import logging

from covcov.infrastructure.db.database import Database
from covcov.infrastructure.configuration import config

logger = logging.getLogger(__name__)
db = Database("database")
#
region         = config["cognito"]["COG_REGION"]
user_pool_id   = config["cognito"]["COG_USER_POOL_ID"]
app_client_id  = config["cognito"]["COG_APP_CLIENT_ID"]

def handle(event, context):
  user_attrs =  event ['request']['userAttributes']

  # https://docs.aws.amazon.com/fr_fr/cognito/latest/developerguide/cognito-user-pool-managing-errors.html / SignUp: UsernameExistsException
  # https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-aliases
  if db.native_execute_sqls([f"select 1 from company where email = '{user_attrs ['email']}'" ])[0] != 0 :
    raise Exception(f": [Email '{user_attrs ['email']}' déjà utilisé. Merci d'en saisir un autre]")

  # event ['userName'] = urllib.parse.unquote_plus(event ['userName'])
  # if db.native_execute_sqls([f"select 1 from company where name = '{event ['userName']}'" ])[0] != 0 :
  #   raise Exception(f": [Nom d'établissement '{event ['userName']}' déjà utilisé. Merci d'en saisir un autre]")

  return event
