Enable email notifications on claim login

This commit is contained in:
rubenwardy 2020-12-15 16:24:49 +00:00
parent 7a4335b8bc
commit c44cc8082c
2 changed files with 4 additions and 3 deletions

@ -24,7 +24,7 @@ from wtforms.validators import *
from app.models import *
from app.tasks.emails import send_verify_email, send_anon_email, send_unsubscribe_verify, send_user_email
from app.utils import randomString, make_flask_login_password, is_safe_url, check_password_hash, addAuditLog
from app.utils import randomString, make_flask_login_password, is_safe_url, check_password_hash, addAuditLog, nonEmptyOrNone
from passlib.pwd import genphrase
from . import bp
@ -228,8 +228,8 @@ def handle_set_password(form):
current_user.password = make_flask_login_password(form.password.data)
if hasattr(form, "email"):
newEmail = form.email.data
if newEmail != current_user.email and newEmail.strip() != "":
newEmail = nonEmptyOrNone(form.email.data)
if newEmail and newEmail != current_user.email:
if EmailSubscription.query.filter_by(email=form.email.data, blacklisted=True).count() > 0:
flash("That email address has been unsubscribed/blacklisted, and cannot be used", "danger")
return

@ -152,6 +152,7 @@ def make_flask_login_password(plaintext):
def login_user_set_active(user: User, *args, **kwargs):
if user.rank == UserRank.NOT_JOINED and user.email is None:
user.rank = UserRank.MEMBER
user.notification_preferences = UserNotificationPreferences(user)
user.is_active = True
db.session.commit()