def METHOD_NAME(app, **kwargs):
    from indico.modules.auth.util import should_skip_redirect_on_insecure_password
    @app.before_request
    def _redirect_if_insecure():
        if not request.endpoint:
            return
        if should_skip_redirect_on_insecure_password(request.endpoint):
            return
        if 'insecure_password_error' not in session:
            return
        if request.method != 'GET':
            raise NoReportError.wrap_exc(Forbidden(_('You need to change your password')))
        if request.is_xhr or request.is_json:
            return
        return redirect(url_for('auth.accounts'))