Exemplo n.º 1
0
def resend(email):
    user = db_session.query(User).filter_by(email=email).first()
    token = user.generate_confirmation_token()
    send_email(user.email,
               _('Account Confirmation'),
               'confirmation',
               user=user,
               token=token)
    flash(_('Email confirmation was sent again'), 'success')
    return redirect(url_for('auth.login'))
Exemplo n.º 2
0
def reset_password_request():
    form = ResetPasswordEmailForm()
    if form.validate_on_submit():
        user = db_session.query(User).filter_by(email=form.email.data).first()
        if user is not None:
            token = user.generate_reset_token()
            send_email(user.email,
                       _('Reset Password'),
                       'reset_password',
                       token=token)
            flash(_('Email with instructions to reset password was sent'),
                  'success')
            return redirect(url_for('auth.login'))
        else:
            flash(_('This email address is not registered!'), 'error')
    display_errors_with_flash(form)
    return render_template('password_reset_request.html', form=form)
Exemplo n.º 3
0
def message_reply(id):
    if not current_user.is_admin():
        abort(403)
    message = db_session.query(Message).filter_by(id=id).first()
    if message is None:
        return redirect(url_for('admin.messages'))

    form = ReplyForm()
    if form.validate_on_submit():
        send_email(message.sender,
                   _('Reply'),
                   'reply',
                   message=message,
                   response=form.response.data)
        flash(_('Response was sent'), 'success')
        db_session.delete(message)
        db_session.commit()
        return redirect(url_for('admin.messages'))

    return render_template('admin_reply.html', message=message, form=form)
Exemplo n.º 4
0
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        user = User(email=form.email.data.lower(), password=form.password.data)
        db_session.add(user)
        db_session.commit()
        token = user.generate_confirmation_token()
        send_email(user.email,
                   _('Account Confirmation'),
                   'confirmation',
                   token=token)
        flash(_('Register success! Please confirm your email before logging'),
              'success')

        if add_anonymous_pack_to_user(user):
            flash(_('Pack was added to your account!'), 'success')

        return redirect(url_for('auth.login'))
    display_errors_with_flash(form)
    return render_template('register.html', form=form)
Exemplo n.º 5
0
def contact():
    form = ContactForm()

    if form.validate_on_submit():
        message = Message(sender=form.email.data,
                          topic=form.topic.data,
                          content=form.content.data,
                          language=str(get_locale()))
        db_session.add(message)
        db_session.commit()

        send_email(config.MAIL_USERNAME, _('Message'), 'contact', form=form)
        flash(_('Message was sent'), 'success')
        return redirect(url_for('main.contact'))

    if current_user.is_authenticated:
        form.email.data = current_user.email

    display_errors_with_flash(form)
    return render_template('contact.html', form=form)