if email, compare id. else, compare username

This commit is contained in:
Fuzzwah 2024-07-27 16:11:52 +10:00 committed by GitHub
parent 39b2cc1c55
commit 3c82d8e3af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,7 +22,11 @@ class UserDetailView(LoginRequiredMixin, DetailView):
def get_object(self, queryset=None):
obj = super().get_object(queryset)
{%- if cookiecutter.username_type == "email" %}
if obj.id != self.request.user.id:
{%- else %}
if obj.username != self.request.user.username:
{%- endif %}
raise PermissionDenied
return obj