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

Fix logout url when custom auth blueprint name #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion flask_peewee/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ def get_admin_url(self, obj):
if model_admin:
return url_for(model_admin.get_url_name('edit'), pk=obj.get_id())

def get_logout_url(self):
return url_for('%s.logout' % self.admin.auth.blueprint.name)

def get_model_name(self, model_class):
model_admin = self.admin.get_admin_for(model_class)
if model_admin:
Expand All @@ -508,7 +511,7 @@ def prepare_environment(self):
self.app.jinja_env.globals['update_querystring'] = self.update_querystring
self.app.jinja_env.globals['get_admin_url'] = self.get_admin_url
self.app.jinja_env.globals['get_model_name'] = self.get_model_name

self.app.jinja_env.globals['get_logout_url'] = self.get_logout_url
self.app.jinja_env.filters['apply_prefix'] = self.apply_prefix


Expand Down
2 changes: 1 addition & 1 deletion flask_peewee/templates/admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<li><a href="/">View site</a></li>
</ul>

<form action="{{ url_for('auth.logout') }}" class="navbar-form pull-right" method="get">
<form action="{{ get_logout_url() }}" class="navbar-form pull-right" method="get">
<button class="btn btn-danger">Logout</button>
</form>
</div>
Expand Down