Create and use a decorator for background functions

This commit is contained in:
Patrick Jentsch
2020-04-21 18:34:21 +02:00
parent 79c9ca97b2
commit bc27744946
12 changed files with 131 additions and 133 deletions

View File

@ -5,7 +5,7 @@ from . import auth
from .forms import (LoginForm, ResetPasswordForm, ResetPasswordRequestForm,
RegistrationForm)
from .. import db
from ..email import create_message, send_async
from ..email import create_message, send
from ..models import User
import os
import shutil
@ -70,7 +70,7 @@ def register():
token = user.generate_confirmation_token()
msg = create_message(user.email, 'Confirm Your Account',
'auth/email/confirm', token=token, user=user)
send_async(msg)
send(msg)
flash('A confirmation email has been sent to you by email.')
return redirect(url_for('auth.login'))
return render_template('auth/register.html.j2',
@ -107,7 +107,7 @@ def resend_confirmation():
token = current_user.generate_confirmation_token()
msg = create_message(current_user.email, 'Confirm Your Account',
'auth/email/confirm', token=token, user=current_user)
send_async(msg)
send(msg)
flash('A new confirmation email has been sent to you by email.')
return redirect(url_for('auth.unconfirmed'))
@ -126,7 +126,7 @@ def reset_password_request():
msg = create_message(user.email, 'Reset Your Password',
'auth/email/reset_password', token=token,
user=user)
send_async(msg)
send(msg)
flash('An email with instructions to reset your password has been '
'sent to you.')
return redirect(url_for('auth.login'))