auth.param.login_after_registration = settings.LOGIN_AFTER_REGISTRATION auth.param.allowed_actions = settings.ALLOWED_ACTIONS auth.param.login_expiration_time = 3600 auth.param.password_complexity = {"entropy": 50} auth.param.block_previous_password_num = 3 auth.param.default_login_enabled = settings.DEFAULT_LOGIN_ENABLED #auth.extra_auth_user_fields=[Field('data_consent', 'boolean', default=False, label='I consent to Net Decision Making holding minimal personal' # ' information to support operation of this site - it is not shared with 3rd parties', # requires=IS_NOT_EMPTY(), error_message='You must consent to register'), auth.extra_auth_user_fields = [ Field('notify', 'string', label='Notification E-mail frequency', requires=IS_IN_SET( ['None', 'Immediate', 'Daily', 'Weekly', 'Monthly']), default='None'), Field('notify_date', 'datetime', readable=False, writable=False), Field('next_notify_date', 'datetime', readable=False, writable=False), #Field('data_consent', 'boolean', default=False, # label='I consent to Net Decision Making holding minimal personal information to support operation of this site - it is not shared with 3rd parties', #requires=IS_NOT_EMPTY(), error_message='You must consent to register') ] auth.define_tables() auth.fix_actions() flash = auth.flash def create_profile_callback(field_values, user_id): print(f"User registered: {user_id}") print(field_values['notify'])
session = Session(secret=settings.SESSION_SECRET_KEY, storage=DBStore(db)) # ####################################################### # Instantiate the object and actions that handle auth # ####################################################### auth = Auth(session, db, define_tables=False) auth.use_username = True auth.param.registration_requires_confirmation = False auth.param.registration_requires_approval = False auth.param.allowed_actions = settings.ALLOWED_ACTIONS auth.param.login_expiration_time = 3600 auth.param.password_complexity = {"entropy": 50} auth.param.block_previous_password_num = 3 auth.extra_auth_user_fields = { Field("avgrating", "integer"), Field('location', 'string'), Field('portfolio', 'string') } auth.define_tables() # ####################################################### # Configure email sender for auth # ####################################################### if settings.SMTP_SERVER: auth.sender = Mailer( server=settings.SMTP_SERVER, sender=settings.SMTP_SENDER, login=settings.SMTP_LOGIN, tls=settings.SMTP_TLS, ssl=settings.SMTP_SSL, )