diff --git a/docs/architecture/authentication.md b/docs/architecture/authentication.md index aa22465e..6bec6773 100644 --- a/docs/architecture/authentication.md +++ b/docs/architecture/authentication.md @@ -20,7 +20,7 @@ These are the steps involved: 1. Backend verifies token and processes request 1. User gets response from authenticated API -``` mermaid +```mermaid sequenceDiagram autonumber participant Cognito User Pool @@ -35,7 +35,6 @@ sequenceDiagram Backend-->>-User:response from authenticated API ``` - ## Current Dev Setup 1. Created app client called "backend within the vrms-dev user pool, with ALLOW_ADMIN_USER_PASSWORD_AUTH enabled @@ -49,6 +48,7 @@ sequenceDiagram 1. Backend should return the user's profile data ## Authentication Guide for Cognito + Before following the below instruction, please ensure you have docker up and running and the build-image running, you can run it with the command `./scripts/buildrun.sh`. 1. Login (or register first then login) to a cognito account [here](https://hackforla-vrms-dev.auth.us-west-2.amazoncognito.com/login?client_id=3e3bi1ct2ks9rcktrde8v60v3u&response_type=token&scope=openid&redirect_uri=http://localhost:8000/admin). Do not worry if you see error messages - you will be using the url to authenticate. diff --git a/docs/how-to/add-model-and-api-endpoints.md b/docs/how-to/add-model-and-api-endpoints.md index 1a8661c8..de9b78f4 100644 --- a/docs/how-to/add-model-and-api-endpoints.md +++ b/docs/how-to/add-model-and-api-endpoints.md @@ -396,12 +396,11 @@ In `app/core/api/views.py` class UserViewSet(viewsets.ModelViewSet): ... - # (1)! - def get_queryset(self): # (2)! + def get_queryset(self): # (1)! """ Optionally filter users by an 'email' and/or 'username' query paramerter in the URL """ - queryset = get_user_model().objects.all() # (3)! + queryset = get_user_model().objects.all() # (2)! email = self.request.query_params.get("email") if email is not None: queryset = queryset.filter(email=email) @@ -412,7 +411,9 @@ In `app/core/api/views.py` ``` 1. Notice the `queryset` property is now the `get_queryset(()` function which returns the queryset. - 1. The `get_queryset()` function overrides the default and lets us filter the objects returned to the client if they pass in a query param. + + The `get_queryset()` function overrides the default and lets us filter the objects returned to the client if they pass in a query param. + 1. Start with all the model objects and filter them based on any available query params. ### Register API endpoints @@ -428,8 +429,8 @@ In `app/core/api/urls.py` 1. [Register](https://www.django-rest-framework.org/api-guide/routers/#usage) the viewset to the [router](https://www.django-rest-framework.org/api-guide/routers/) ```python title="app/core/api/urls.py" linenums="1" - # (1)! router.register(r"recurring-events", RecurringEventViewSet, basename="recurring-event") + # (1)! ``` 1. Params