def __init__(self, request): self.request = request cp = ControlPanel(request) self.token_duration = cp.get_value(authentication_schema.name, 'token_duration') self.login_view = LoginView(request) self.frm = make_password_reset_form(self.request)
def notify_account_created(event): """Notify site admins when an account is created. """ logger = getLogger('speak_friend.user_activity') path = 'speak_friend:templates/email/account_creation_notification.pt' settings = event.request.registry.settings subject = '%s: New user created' % settings['site_name'] mailer = get_mailer(event.request) headers = {'Reply-To': event.user.full_email} response = render_to_response(path, {'profile': event.user}, event.request) # Obtain list of emails to notify from the control panel cp = ControlPanel(event.request) recipients = cp.get_value(email_notification_schema.name, 'user_creation', []) if not recipients: logger.info('No one to notify of account creation: %s.', event.user) return message = Message(subject=subject, sender=settings['site_from'], recipients=recipients, extra_headers=headers, html=response.unicode_body) mailer.send(message)
def __init__(self, request): self.request = request self.frm = make_contact_us_form(self.request) settings = request.registry.settings self.subject = "Contact Us Form Submission: %s" % settings['site_name'] self.sender = settings['site_from'] cp = ControlPanel(request) self.recipients = cp.get_value(email_notification_schema.name, 'contact_us', [])
def token_expired(request): cp = ControlPanel(request) token_duration = cp.get_value(authentication_schema.name, 'token_duration') request.response.status = "400 Bad Request" url = request.route_url('request_password') return { 'token_duration': token_duration, 'request_reset_url': url, }
def test_get_value(self): # Make sure the default value bubbles up correctly request = testing.DummyRequest() request.user = None request.db_session = MockSession() cp = ControlPanel(request) authentication_schema token_duration = cp.get_value(authentication_schema.name, 'token_duration') self.assertTrue(token_duration == TOKEN_DURATION)
def __init__(self, request, max_attempts=None): self.request = request self.pass_ctx = request.registry.password_context contact_url = request.route_url('contact_us') contact_link = '<a href="%s">contact us</a>' % contact_url self.disabled_error = "Your account has been disabled. Please %s if you'd like us to reactivate your account." % contact_link self.invalid_error = 'Username or password is invalid.' self.locked_error = 'Your account has been disabled. ' \ 'Check your email for instructions to reset your password.' query = self.request.GET.items() action = request.route_url('login', _query=query) self.frm = make_login_form(request, action) if max_attempts is None: cp = ControlPanel(request) self.max_attempts = cp.get_value(authentication_schema.name, 'max_attempts', MAX_DOMAIN_ATTEMPTS)