Skip to content

Commit

Permalink
Permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
blopker committed Nov 6, 2023
1 parent e208d43 commit f1b5b33
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion totem/circles/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_anon_subscribe(self):
def test_anon_subscribe_wrong_token(self):
url = reverse("circles:subscribe", args=[self.circle.slug])
response = self.client.get(f"{url}?user={self.user.slug}&token=wrong-token")
assert response.status_code == 404
assert response.status_code == 403
self.assertFalse(self.user in self.circle.subscribed.all())

def test_anon_subscribe_no_token(self):
Expand Down
4 changes: 2 additions & 2 deletions totem/circles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ def _token_subscribe(request: HttpRequest, circle: Circle):
sent_token = request.GET.get("token")

if not user_slug or not sent_token:
raise Http404
raise PermissionDenied

user = User.objects.get(slug=user_slug)
token = circle.subscribe_token(user)

if sent_token != token:
raise Http404
raise PermissionDenied

if request.GET.get("action") == "unsubscribe":
circle.unsubscribe(user)
Expand Down

0 comments on commit f1b5b33

Please sign in to comment.