Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make redirect after logout configurable #1154

Closed
jeverling opened this issue Oct 4, 2019 · 3 comments · Fixed by #1749
Closed

Make redirect after logout configurable #1154

jeverling opened this issue Oct 4, 2019 · 3 comments · Fixed by #1749

Comments

@jeverling
Copy link
Contributor

Hi all,

I think it would be really useful if the URL that Flask-Appbuilder redirects to after logout would be configurable - akin to Django's LOGOUT_REDIRECT_URL setting.

Right now, the user is redirected to the hompage:

flask_appbuilder/security/views.py#L477

class AuthView(BaseView):
    route_base = ""
    login_template = ""
    invalid_login_message = lazy_gettext("Invalid login. Please try again.")
    title = lazy_gettext("Sign In")

    @expose("/login/", methods=["GET", "POST"])
    def login(self):
        pass

    @expose("/logout/")
    def logout(self):
        logout_user()
        return redirect(self.appbuilder.get_url_for_index)

This might not be what is desired though, maybe the user should see a "thank you and see you soon page" or something like that, and it can also lead to problems with setups that use oauth2 for authentication, because the user will be logged straight back in if the oauth2 provider is configured to allow login without a prompt. I think this is what happens in #1110
So I think having an option to configure where users are redirected to after logout would be really useful, e.g.

    return redirect(
        self.appbuilder.app.config.get(
            "LOGOUT_REDIRECT_URL", self.appbuilder.get_url_for_index
        )
    )
@dpgaspar
Copy link
Owner

dpgaspar commented Oct 7, 2019

Agree, are you willing to submit a PR for it?

@jeverling
Copy link
Contributor Author

jeverling commented Oct 7, 2019

I'm happy to do that, but it'll be a few days until I'm able to work on it.

jeverling added a commit to jeverling/Flask-AppBuilder that referenced this issue Oct 13, 2019
jeverling added a commit to jeverling/Flask-AppBuilder that referenced this issue Oct 13, 2019
@stale
Copy link

stale bot commented Jan 5, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Feel free to reopen it if it's still relevant to you. Thank you

@stale stale bot added the stale label Jan 5, 2020
@stale stale bot closed this as completed Jan 12, 2020
dpgaspar added a commit that referenced this issue Dec 9, 2021
* Use config["LOGOUT_REDIRECT_URL"] - see #1154

* Docs & test for LOGOUT_REDIRECT_URL - fixes #1154

* Upstream changes for test_menu.py

* Fix rST table row alignment

Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>

Co-authored-by: Jesaja Everling <jeverling@gmail.com>
Co-authored-by: Daniel Vaz Gaspar <danielvazgaspar@gmail.com>
Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants