()
return render_template('forgot.html', form=form)
If NOTIFICO_PASSWORD_RESET is enabled and Flask-Mail is configured,
    this view allows you to request a password reset email. It also
    handles accepting those tokens.
If NOTIFICO_PASSWORD_RESET is enabled and Flask-Mail is configured,
    this view allows you to request a password reset email. It also
    handles accepting those tokens.
If NOTIFICO_PASSWORD_RESET is enabled and Flask - Mail is configured this view allows you to request a password reset email . It also handles accepting those tokens .
def forgot_password():
    """
    If NOTIFICO_PASSWORD_RESET is enabled and Flask-Mail is configured,
    this view allows you to request a password reset email. It also
    handles accepting those tokens.
    """
    # Because this functionality depends on Flask-Mail and
    # celery being properly configured, we default to disabled.
    if not current_app.config.get('NOTIFICO_PASSWORD_RESET'):
        flash(
            'Password resets have been disabled by the administrator.',
            category='warning'
        )
        return redirect('.login')

    # How long should reset tokens last? We default
    # to 24 hours.
    token_expiry = current_app.config.get(
        'NOTIFICO_PASSWORD_RESET_EXPIRY',
        60 * 60 * 24
    )

    form = UserForgotForm()
    if form.validate_on_submit():
        user = User.by_username(form.username.data)
        new_token = reset.add_token(user, expire=token_expiry)

        # Send the email as a background job so we don't block
        # up the browser (and to use celery's built-in rate
        # limiting).
        background.send_mail.delay(
            'Notifico - Password Reset for {username}'.format(
                username=user.username
            ),
            # We're already using Jinja2, so we might as well use
            # it to render our email templates as well.
            html=render_template(
                'email_reset.html',
                user=user,
                reset_link=url_for(
                    '.reset_password',
                    token=new_token,
                    uid=user.id,
                    _external=True
                ),
                hours=token_expiry / 60 / 60
            ),
            recipients=[user.email],
            sender=current_app.config['NOTIFICO_MAIL_SENDER']
        )
        flash('A reset email has been sent.', category='success')
        return redirect(url_for('.login'))

    return render_template('forgot.html', form=form)
def forgot_password ( ) : # Because this functionality depends on Flask-Mail and # celery being properly configured, we default to disabled. if not current_app . config . get ( 'NOTIFICO_PASSWORD_RESET' ) : flash ( 'Password resets have been disabled by the administrator.' , category = 'warning' ) return redirect ( '.login' ) # How long should reset tokens last? We default # to 24 hours. token_expiry = current_app . config . get ( 'NOTIFICO_PASSWORD_RESET_EXPIRY' , 60 * 60 * 24 ) form = UserForgotForm ( ) if form . validate_on_submit ( ) : user = User . by_username ( form . username . data ) new_token = reset . add_token ( user , expire = token_expiry ) # Send the email as a background job so we don't block # up the browser (and to use celery's built-in rate # limiting). background . send_mail . delay ( 'Notifico - Password Reset for {username}' . format ( username = user . username ) , # We're already using Jinja2, so we might as well use # it to render our email templates as well. html = render_template ( 'email_reset.html' , user = user , reset_link = url_for ( '.reset_password' , token = new_token , uid = user . id , _external = True ) , hours = token_expiry / 60 / 60 ) , recipients = [ user . email ] , sender = current_app . config [ 'NOTIFICO_MAIL_SENDER' ] ) flash ( 'A reset email has been sent.' , category = 'success' ) return redirect ( url_for ( '.login' ) ) return render_template ( 'forgot.html' , form = form )