Beispiel #1
0
 def __call__(self):
     tapi = TemplateAPI(self.context, self.request, 'Trash')
     if self.error is None:
         self.fill_deleted()
     else:
         tapi.set_status_message(unicode(self.error))
     return {'api': tapi, 'deleted': self.deleted}
Beispiel #2
0
 def __call__(self):
     tapi = TemplateAPI(self.context, self.request, 'Trash')
     if self.error is None:
         self.fill_deleted()
     else:
         tapi.set_status_message(unicode(self.error))
     return {'api': tapi, 'deleted': self.deleted}
Beispiel #3
0
 def __call__(self):
     tapi = TemplateAPI(self.context, self.request, 'Trash')
     if self.error is None:
         self.fill_deleted()
     else:
         tapi.set_status_message(unicode(self.error))
     layout = self.request.layout_manager.layout
     layout.page_title += ' Trash'
     return {'api': tapi, 'deleted': self.deleted}
Beispiel #4
0
def configure_twofactor_view(context, request):
    page_title = "Profile: %s" % context.title
    api = TemplateAPI(context, request, page_title)

    tf = TwoFactor(context, request)
    if (not tf.enabled or not tf.phone_factor_enabled or
            not authenticated_userid(request) == context.__name__):
        return HTTPFound(request.resource_url(context))

    form = 'number'
    number = ''
    if request.method == 'POST':
        number = request.POST.get('phonenumber', '')
        if 'form.verifyemail.submitted' in request.POST:
            number = ''.join(n for n in number if n in string.digits)
            if len(number) == 10:
                context.two_factor_phone = number
                code = context._two_factor_verify_code = make_random_code(6)
                msg = "%s phone verification code: %s" % (
                    get_setting(context, 'title'),
                    code)
                tf.send_text_to_number(number, msg)
                api.set_status_message('Verification code sent to phone number: %s' % number)
                form = 'verify'
            else:
                api.set_status_message('Invalid phone number')
        elif 'form.verifycode.submitted' in request.POST:
            form = 'verify'
            code = request.POST['code']
            if code == context._two_factor_verify_code:
                context._two_factor_verify_code = ''
                context.two_factor_verified = True
                form = 'success'
            else:
                api.set_status_message('Invalid verification code')
    return dict(
        api=api,
        form=form,
        number=number,
        context=context)
Beispiel #5
0
def configure_twofactor_view(context, request):
    page_title = "Profile: %s" % context.title
    api = TemplateAPI(context, request, page_title)

    tf = TwoFactor(context, request)
    if (not tf.enabled or not tf.phone_factor_enabled
            or not authenticated_userid(request) == context.__name__):
        return HTTPFound(request.resource_url(context))

    form = 'number'
    number = ''
    if request.method == 'POST':
        number = request.POST.get('phonenumber', '')
        if 'form.verifyemail.submitted' in request.POST:
            number = ''.join(n for n in number if n in string.digits)
            if len(number) == 10:
                context.two_factor_phone = number
                code = context._two_factor_verify_code = make_random_code(6)
                msg = "%s phone verification code: %s" % (get_setting(
                    context, 'title'), code)
                tf.send_text_to_number(number, msg)
                api.set_status_message(
                    'Verification code sent to phone number: %s' % number)
                form = 'verify'
            else:
                api.set_status_message('Invalid phone number')
        elif 'form.verifycode.submitted' in request.POST:
            form = 'verify'
            code = request.POST['code']
            if code == context._two_factor_verify_code:
                context._two_factor_verify_code = ''
                context.two_factor_verified = True
                form = 'success'
            else:
                api.set_status_message('Invalid verification code')
    return dict(api=api, form=form, number=number, context=context)