Ejemplo n.º 1
0
    def send_button(self, *args, **input):

        if mail_form.validate(input):

            if False and 'attachment' in input and hasattr(
                    input['attachment'], 'filename'):
                send(
                    input['recipient'],
                    input['subject'],
                    input['message'],
                    [
                        Attachment(
                            input['attachment'].filename,
                            input['attachment'].file,
                        )
                    ],
                )
                success('message sent with attachment')
            else:
                send_as(
                    (input['from_name'], input['from_email']),
                    input['recipient'],
                    input['subject'],
                    input['message'],
                )
                success('message sent')

            return home('mail')
Ejemplo n.º 2
0
 def save_password_button(self, key, *args, **data):
     form = get_reset_password_form(key)
     if form.validate(data):
         user = context.site.users.first(username=key)
         if user:
             new_password = form.evaluate()['new_password']
             user.set_password(new_password)
             success('password updated')
             return home('users/' + key)
Ejemplo n.º 3
0
 def save_password_button(self, key, *args, **data):
     form = get_reset_password_form(key)
     if form.validate(data):
         user = context.site.users.first(username=key)
         if user:
             new_password = form.evaluate()['new_password']
             user.set_password(new_password)
             message = 'password updated'
             if form.evaluate()['email_password']:
                 model.send_password(user, new_password)
                 message += ' and sent'
             zoom.alerts.success(message)
             return home('users/' + key)
Ejemplo n.º 4
0
def reset_password(token, password, confirm):
    """reset the user password"""
    if not valid_token(token):
        return page(load_content('expired.md'))
    elif not valid_new_password(password):
        error('Invalid password ({})'.format(valid_new_password.msg))
    elif password != confirm:
        error('Passwords do not match')
    else:
        user = user_by_token(token)
        if user:
            user.set_password(password)
            token_rec = get_tokens().delete(token=token)
            return home('complete')
        else:
            error('Invalid request')
Ejemplo n.º 5
0
    def reset_button(self, *args, **data):
        if form.validate(data):
            email = form.evaluate()['email']

            if 'testco' in email:
                if context.user.is_admin:
                    content = model.initiate_password_reset(email, fake=True)
                    msg = '<i>This message would be sent to user.</i><hr>'
                    return page(msg + content, title='Password Reset Message')
                else:
                    error('invalid email address')
                    return False

            err = model.initiate_password_reset(email)
            if err:
                error(err)
            else:
                return home('step2')

        error('please enter a valid email address')
Ejemplo n.º 6
0
 def deactivate(self, key):
     user = context.site.users.first(username=key)
     user.deactivate()
     user.save()
     return home('users/' + key)
Ejemplo n.º 7
0
 def deactivate(self, key):
     user = zoom.get_site().users.locate(key)
     if user:
         user.deactivate()
     return home('users/' + key)
Ejemplo n.º 8
0
 def deactivate(self, key):
     user = zoom.system.site.users.first(username=key)
     if user:
         user.deactivate()
     return home('users/' + key)