if the customer sign in and he has permission to see the data that the admin has given to him, he will see the data after he sign in, but if the admin doesn\'t give him permissi
def staff_only(view_func):
def wrapper_function(request, *args, **kwargs):
group = None
if request.user.groups.exists():
group = request.user.groups.all()[0].name
if group == 'registrar':
return redirect('adminpage')
if group == 'admin':
return view_func(request, *args, **kwargs)
return redirect("loginpage")
return wrapper_function
This function is missing case when a user does not have required groups, in this case, either we should either redirect a user to login page send to another page or display like "You don't have access to this page"