Skip to content

docs(jwt): Fix endpoints table and add missing logout route#16

Merged
DevlTz merged 10 commits intomainfrom
feat/devltz/jwt
Apr 7, 2026
Merged

docs(jwt): Fix endpoints table and add missing logout route#16
DevlTz merged 10 commits intomainfrom
feat/devltz/jwt

Conversation

@DevlTz
Copy link
Copy Markdown
Owner

@DevlTz DevlTz commented Mar 30, 2026

The JWT endpoints table in docs/jwt.md was malformed and missing the logout endpoint despite it being wired up in the URL conf via TokenBlacklistView.

Changes

  • docs/jwt.md: Corrected markdown table formatting (single | separators, single header separator row); added missing POST /api/users/logout/ row documenting the blacklist-based logout endpoint.
Método Endpoint Acesso Descrição
POST /api/users/logout/ Autenticado Invalida o refresh token (blacklist), encerrando a sessão.

@DevlTz DevlTz requested a review from Copilot April 1, 2026 21:02
@DevlTz DevlTz self-assigned this Apr 1, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds JWT-based authentication to the HomeMatch Django/DRF API (SimpleJWT), including registration/login/logout endpoints and supporting documentation/diagrams.

Changes:

  • Configure SimpleJWT (incl. refresh rotation + blacklist) and enable the blacklist app in Django settings.
  • Add public registration endpoint plus JWT login/refresh/logout routes; rename the authenticated “profile” action to /me.
  • Add documentation for authentication/security plus database diagrams (mermaid + PNG).

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
docs/jwt.md New JWT/auth documentation and example requests.
docs/diagrama_database.mermaid Adds a mermaid ER diagram for the project schema.
docs/diagram.png Adds an image version of the database diagram.
config/settings.py Enables SimpleJWT + blacklist app and sets JWT lifetimes/rotation behavior.
apps/users/views.py Adds RegisterUserView and renames profile action to me; keeps favorites endpoint.
apps/users/urls.py Adds /register, /login, /token/refresh, /logout routes alongside router endpoints.
apps/users/serializers.py Adds RegisterSerializer for user creation.
apps/users/models.py Introduces a custom UserManager for email-based auth.
apps/users/migrations/0003_alter_user_managers.py Adds a migration altering model managers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AUTH_PASSWORD_VALIDATORS entry has inconsistent indentation for the dict key, which makes the settings file harder to read and deviates from the surrounding style. Align the "NAME" line indentation with the other dict entries.

Suggested change
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"

Copilot uses AI. Check for mistakes.

class RegisterUserView(generics.CreateAPIView):
queryset = User.objects.all()
permission_classes = [AllowAny]
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permission_classes = [AllowAny] has trailing whitespace. Please remove it to satisfy linters/formatters and keep diffs clean.

Suggested change
permission_classes = [AllowAny]
permission_classes = [AllowAny]

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +21
raise ValueError("Superuser need is_staff=True.")
if extra_fields.get("is_superuser") is not True:
raise ValueError("Superuser need is_superuser=True.")
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error messages in these ValueErrors have grammatical issues ("Superuser need ..."). Adjust wording to be clear and correct (e.g., "Superuser needs is_staff=True.") so these messages are useful when surfaced in CLI/admin flows.

Suggested change
raise ValueError("Superuser need is_staff=True.")
if extra_fields.get("is_superuser") is not True:
raise ValueError("Superuser need is_superuser=True.")
raise ValueError("Superuser needs is_staff=True.")
if extra_fields.get("is_superuser") is not True:
raise ValueError("Superuser needs is_superuser=True.")

Copilot uses AI. Check for mistakes.
Comment on lines 33 to +36
@action(detail=False, methods=['get', 'post', 'delete'], url_path='favorites')
def favorites(self, request):
from apps.properties.serializers import PropertiesSerializer # Sei que soa estranho, mas esse import tem que tá aqui praa poder não ter import repetido
from apps.properties.models import Properties
from apps.properties.models import Properties
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint relies on user.favorites (used later in the method), but the User model in this PR does not define a favorites relation (the ManyToMany field is commented out and there is no alternative relation in apps/properties). This will raise an AttributeError at runtime. Either add/restore the favorites ManyToMany (with a migration) or update the endpoint to use the actual persisted favorites model/table.

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +27
| Método | Endpoint | Acesso | Descrição |
| :--- | :--- | :--- | :--- |
| `POST` | `/api/users/register/` | Público | Registra um novo usuário na plataforma. |
| `POST` | `/api/users/login/` | Público | Recebe as credenciais e retorna os tokens `access` e `refresh`. |
| `POST` | `/api/users/token/refresh/` | Público | Gera um novo `access` token utilizando um `refresh` válido. |
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The markdown table for the JWT endpoints is malformed (rows start with ||), which prevents proper rendering in standard Markdown parsers. Use single | separators and a single header separator row.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dc2c90a. The table now uses proper single | separators and I also added the missing POST /api/users/logout/ row, which was already defined in the URL conf but omitted from the docs.

"password": "sua senha cadastrada"
}'
```
* Só ai, você testa com seu token.
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence has a spelling/grammar issue ("Só ai"). Please correct to "Só aí" for proper Portuguese.

Suggested change
*ai, você testa com seu token.
*, você testa com seu token.

Copilot uses AI. Check for mistakes.
Comment on lines +109 to +110
from datetime import timedelta
SIMPLE_JWT = {
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep imports grouped at the top of the module. timedelta is imported mid-file, which makes settings harder to scan and can conflict with linting rules.

Copilot uses AI. Check for mistakes.
Comment on lines +111 to +114
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=60),
'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
'ROTATE_REFRESH_TOKENS': True,
'BLACKLIST_AFTER_ROTATION': True,
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quote style is inconsistent: this settings file largely uses double quotes, but SIMPLE_JWT uses single quotes for keys. Standardize the quoting style to match the rest of the file to keep formatting consistent.

Suggested change
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=60),
'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
'ROTATE_REFRESH_TOKENS': True,
'BLACKLIST_AFTER_ROTATION': True,
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=60),
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True,

Copilot uses AI. Check for mistakes.
user_type=validated_data['user_type'],
password=validated_data['password']
)
return user
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a blank line between create and validate_email. Having def validate_email immediately after return user violates PEP 8 and makes the serializer harder to read.

Suggested change
return user
return user

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +18
operations = [
migrations.AlterModelManagers(
name='user',
managers=[
],
),
]
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration alters model managers but provides an empty managers=[], which is unusual and can create confusing migration state (and it doesn't affect the DB schema). Consider removing it, or include the intended manager so the migration accurately represents the model state.

Suggested change
operations = [
migrations.AlterModelManagers(
name='user',
managers=[
],
),
]
operations = []

Copilot uses AI. Check for mistakes.
Copilot AI changed the title Feat/devltz/jwt docs(jwt): Fix endpoints table and add missing logout route Apr 7, 2026
@DevlTz DevlTz merged commit f28d0fe into main Apr 7, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants