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

chore: Redirect to prev url on login #1747

Merged
merged 5 commits into from
Dec 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions flask_appbuilder/security/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from ..views import expose, ModelView, SimpleFormView
from ..widgets import ListWidget, ShowWidget


log = logging.getLogger(__name__)


Expand Down Expand Up @@ -514,7 +513,10 @@ def login(self):
flash(as_unicode(self.invalid_login_message), "warning")
return redirect(self.appbuilder.get_url_for_login)
login_user(user, remember=False)
return redirect(self.appbuilder.get_url_for_index)
next_url = request.args.get("next", "")
if not next_url:
next_url = self.appbuilder.get_url_for_index
return redirect(next_url)
return self.render_template(
self.login_template, title=self.title, form=form, appbuilder=self.appbuilder
)
Expand All @@ -536,7 +538,10 @@ def login(self):
flash(as_unicode(self.invalid_login_message), "warning")
return redirect(self.appbuilder.get_url_for_login)
login_user(user, remember=False)
return redirect(self.appbuilder.get_url_for_index)
next_url = request.args.get("next", "")
if not next_url:
next_url = self.appbuilder.get_url_for_index
return redirect(next_url)
return self.render_template(
self.login_template, title=self.title, form=form, appbuilder=self.appbuilder
)
Expand Down Expand Up @@ -584,7 +589,10 @@ def after_login(resp):
session.pop("remember_me", None)

login_user(user, remember=remember_me)
return redirect(self.appbuilder.get_url_for_index)
next_url = request.args.get("next", "")
if not next_url:
next_url = self.appbuilder.get_url_for_index
return redirect(next_url)

return login_handler(self)

Expand Down