Forums

flask-security redirect after login

Is there a way to customize where to redirect after flask-security login?

Flask security has a setting called SECURITY_POST_LOGIN_VIEW that might help. See here.

And I think you do something like this:

app.config['SECURITY_POST_LOGIN_VIEW'] = '/url-after-login'

Thanks conrad. Can we tune this setting something like this?

If profile_complete:
    app.config['SECURITY_POST_LOGIN_VIEW'] = '/posts'
else:
    app.config['SECURITY_POST_LOGIN_VIEW'] = '/edit_profile'

Will this work? If yes, can it be in the top where it is declared?

Thanks

I have a feeling you should instead say go to a view called post_login_view_that_decides_whether_to_send_user_to_posts_or_edit_profile. and within that view, either redirect to posts or to edit_profile depending on whether profile_complete or not.