-
Hi, thanks for the work for this amazing packages I going to make my own apps thats make user registrations with custome functions and views (registration for customer pov), it's very easy to create because @bp.route(f"/{PREFIX}/create", methods=["GET", "POST"])
@auth_required("session")
@roles_required("Admin")
def user_create():
form = ExtendedRegisterForm()
if form.validate_on_submit():
""" create new user """
new_user = user_datastore.create_user(
email=form.email.data, password=hash_password(form.password.data)
)
if form.role.data:
""" if role form exist, so add role to user """
user_datastore.add_role_to_user(new_user, form.role.data)
db.session.commit()
# trigger the email
flash(_default_messages["SUCCESS"][0], _default_messages["SUCCESS"][1])
return redirect(url_for("back.user"))
return render_template(
bp.__getattribute__("name") + f"/{PREFIX}/" + "create.html",
page_title=PREFIX,
register_user_form=form,
) Thank you. I hope any body can give me suggest. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You don't need to subclass MailUtil - I presume you have already configured an email program - such as Flask-Mail - and that is working. Where you want to send an email - just call the appropriate flask_mail methods - e.g. send_mail. You can look at the source for flask_security mail_util.py to see the 5 or so lines of code necessary. |
Beta Was this translation helpful? Give feedback.
You don't need to subclass MailUtil - I presume you have already configured an email program - such as Flask-Mail - and that is working. Where you want to send an email - just call the appropriate flask_mail methods - e.g. send_mail. You can look at the source for flask_security mail_util.py to see the 5 or so lines of code necessary.