conn = redis.Redis(host=host, port=int(port)) conn.set = (lambda k, v, e, cs=conn.set, ct=conn.ttl: cs(k, v, ct(k)) if ct(k) >= 0 else cs(k, v, e)) session = Session(secret=settings.SESSION_SECRET_KEY, storage=conn) elif settings.SESSION_TYPE == "memcache": import memcache, time conn = memcache.Client(settings.MEMCACHE_CLIENTS, debug=0) session = Session(secret=settings.SESSION_SECRET_KEY, storage=conn) elif settings.SESSION_TYPE == "database": from py4web.utils.dbstore import DBStore session = Session(secret=settings.SESSION_SECRET_KEY, storage=DBStore(db)) auth = Auth(session, db, define_tables=False) auth.use_username = True auth.param.registration_requires_confirmation = settings.VERIFY_EMAIL auth.param.registration_requires_approval = settings.REQUIRES_APPROVAL auth.allowed_actions = ["all"] auth.login_expiration_time = 3600 auth.password_complexity = {"entropy": 50} auth.block_previous_password_num = 3 auth.define_tables() 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,
auth_messages = copy.deepcopy(auth.MESSAGES) auth_messages['buttons']['sign-in'] = "Log in" auth_messages['buttons']['sign-up'] = "Sign up" auth_messages['buttons']['lost-password'] = "******" # And button classes. auth_button_classes = { "lost-password": "******", "register": "button is-info is-light", "request": "button is-primary", "sign-in": "button is-primary", "sign-up": "button is-success", "submit": "button is-primary", } auth.use_username = False auth.param.button_classes = auth_button_classes 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 # FIXME: Readd for production. auth.param.password_complexity = {"entropy": 2} auth.param.block_previous_password_num = 3 auth.param.formstyle = FormStyleBulma auth.define_tables() # ####################################################### # Configure email sender for auth # ####################################################### if settings.SMTP_SERVER: