Skip to content

Commit

Permalink
Fix for infinite redirects caused by lacking permissions, closes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed May 16, 2021
1 parent 1abe5f7 commit f994437
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django_sql_dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Meta:
}


@permission_required("django_sql_dashboard.execute_sql")
@permission_required("django_sql_dashboard.execute_sql", raise_exception=True)
def dashboard_index(request):
sql_queries = []
too_long_so_use_post = False
Expand Down
7 changes: 7 additions & 0 deletions test_project/test_dashboard_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ def test_anonymous_users_denied(client):
assert response.url == "/accounts/login/?next=/dashboard/%3Fsql%3Dselect%2B1"


def test_user_without_permission_gets_403(client, dashboard_db):
user = User.objects.create(username="noperm", is_active=True, is_staff=True)
client.force_login(user)
response = client.get("/dashboard/")
assert response.status_code == 403


def test_superusers_allowed(admin_client, dashboard_db):
response = admin_client.get("/dashboard/")
assert response.status_code == 200
Expand Down

0 comments on commit f994437

Please sign in to comment.