Ejemplo n.º 1
0
def send_password_reset_notice(user):
    """Sends the password reset notice email for the specified user.

    :param user: The user to send the notice to
    """
    if config_value('SEND_PASSWORD_RESET_NOTICE_EMAIL'):
        send_mail(config_value('EMAIL_SUBJECT_PASSWORD_NOTICE'), [user.email],
                  'reset_notice', user=user)
Ejemplo n.º 2
0
def send_reset_password_instructions(user):
    """Sends the reset password instructions email for the specified user.

    :param user: The user to send the instructions to
    """
    token = generate_reset_password_token(user)
    reset_link = url_for(
        'login.reset_password', token=token, _external=True
    )

    if config_value('SEND_PASSWORD_RESET_EMAIL'):
        send_mail(config_value('EMAIL_SUBJECT_PASSWORD_RESET'), [user.email],
                  'reset_instructions',
                  user=user, reset_link=reset_link)

    reset_password_instructions_sent.send(
        current_app._get_current_object(), user=user, token=token
    )
Ejemplo n.º 3
0
def register_user(**kwargs):
    security = current_app.extensions.get('security')
    confirmation_link, token = None, None
    kwargs['password'] = hash_password(kwargs['password'])
    user = g.datastore.create_user(**kwargs)

    if security.confirmable:
        confirmation_link, token = generate_confirmation_link(user)
        flash(*get_message('CONFIRM_REGISTRATION', email=user.email))

    user_registered.send(current_app._get_current_object(),
                         user=user, confirm_token=token)

    if config_value('SEND_REGISTER_EMAIL'):
        send_mail(config_value('EMAIL_SUBJECT_REGISTER'), [user.email],
                  'welcome', user=user, confirmation_link=confirmation_link)

    return user
Ejemplo n.º 4
0
def send_confirmation_instructions(user, email=None):
    """Sends the confirmation instructions email for the specified user.
    :param user: The user to send the instructions to
    :param email: if sending to an email address other than the user's primary
        - email is currently only used when changing a user's email, so we send to the new address
    """
    confirmation_url = None
    if not email:
        email = user.email
    else:
        confirmation_url = 'login.confirm_email_modification'

    confirmation_link, token = generate_confirmation_link(user, confirmation_url=confirmation_url)

    send_mail(config_value('EMAIL_SUBJECT_CONFIRM'), [email],
              'confirmation_instructions', user=user,
              confirmation_link=confirmation_link)

    confirm_instructions_sent.send(current_app._get_current_object(), user=user,
                                   token=token)
Ejemplo n.º 5
0
def send_password_changed_notice(user):
    send_mail(config_value(['EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE']), [user.email],
              'change_notice')