registration: Add code to actually send registration emails
This commit is contained in:
parent
12ce7cbb50
commit
d1045226a1
1 changed files with 12 additions and 1 deletions
|
@ -4,8 +4,9 @@ import flask_login
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from goathacks.registration.forms import LoginForm, RegisterForm
|
from goathacks.registration.forms import LoginForm, RegisterForm
|
||||||
from werkzeug.security import check_password_hash, generate_password_hash
|
from werkzeug.security import check_password_hash, generate_password_hash
|
||||||
|
from flask_mail import Message
|
||||||
|
|
||||||
from goathacks import db
|
from goathacks import db, mail as app_mail
|
||||||
from goathacks.models import User
|
from goathacks.models import User
|
||||||
|
|
||||||
bp = Blueprint('registration', __name__, url_prefix="/registration")
|
bp = Blueprint('registration', __name__, url_prefix="/registration")
|
||||||
|
@ -55,6 +56,16 @@ def register():
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flask_login.login_user(user)
|
flask_login.login_user(user)
|
||||||
|
|
||||||
|
if waitlisted:
|
||||||
|
msg = Message("Goathacks - Waitlist Confirmation")
|
||||||
|
else:
|
||||||
|
msg = Message("GoatHacks - Registration Confirmation")
|
||||||
|
|
||||||
|
msg.add_recipient(user.email)
|
||||||
|
msg.sender = ("GoatHacks Team", "hack@wpi.edu")
|
||||||
|
msg.body = render_template("emails/registration.txt", user=user)
|
||||||
|
app_mail.send(msg)
|
||||||
|
|
||||||
return redirect(url_for("dashboard.home"))
|
return redirect(url_for("dashboard.home"))
|
||||||
else:
|
else:
|
||||||
flash("Passwords do not match")
|
flash("Passwords do not match")
|
||||||
|
|
Loading…
Add table
Reference in a new issue