Skip to content

Commit

Permalink
fix: correct user information on request (descope#149)
Browse files Browse the repository at this point in the history
## Related Issues

Fixes descope#148

## Description

This shows a valid example of how to access the Descope attributes in
the ProxyModel for the user.
  • Loading branch information
omercnet authored Jun 6, 2023
1 parent 66b0f92 commit 94c29f7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion example_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ def get(self, request: HttpRequest):
class Index(View):
def get(self, request: HttpRequest):
logger.info("Index view called")
return JsonResponse(request.session.get("user", {}))
return JsonResponse(
{
"user": request.user.username,
"is_authenticated": request.user.is_authenticated,
"is_staff": request.user.is_staff,
"is_superuser": request.user.is_superuser,
"email": request.user.email,
}
)

0 comments on commit 94c29f7

Please sign in to comment.