Skip to content

Feat/add user models#2

Merged
RokuSennyou merged 16 commits intodevfrom
feat/add-user
Oct 3, 2025
Merged

Feat/add user models#2
RokuSennyou merged 16 commits intodevfrom
feat/add-user

Conversation

@RokuSennyou
Copy link
Copy Markdown
Member

This pull request introduces a custom user model and profile system, integrates JWT-based authentication, and adds API endpoints for user registration, login, profile retrieval, and token refresh. It also updates admin management and documentation to support these changes, ensuring both backend and frontend developers have clear guidance.

Authentication and User Model Integration

  • Implemented a custom User model with UUID primary key, unique email, real name, and identity field (student/teacher/admin), along with a related UserProfile model for additional user info such as student_id, bio, and avatar. [1] [2]
  • Configured Django settings to use the custom user model (AUTH_USER_MODEL), enabled JWT authentication with rest_framework_simplejwt, and set up media file handling for avatar uploads. [1] [2]

API Endpoints and Serializers

  • Added API endpoints for user registration (/auth/signup/), login (/auth/session/), token refresh (/auth/refresh), and profile retrieval (/auth/me), with corresponding serializers for input validation and response formatting. [1] [2] [3]

Admin and Signals

  • Enhanced Django admin with custom management for User and UserProfile, and implemented a signal to automatically create a profile when a user is registered. [1] [2] [3]

Documentation Updates

  • Added a comprehensive frontend API documentation (docs/frontend.MD) detailing authentication endpoints, request/response formats, error messages, and usage examples for frontend integration.
  • Updated the main README.md to clarify documentation for backend and frontend developers.

@RokuSennyou RokuSennyou requested a review from Copilot October 3, 2025 16:21
Copy link
Copy Markdown
Contributor

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

This PR introduces a comprehensive user authentication system to the Django backend, implementing JWT-based authentication with custom user models and API endpoints for frontend integration.

  • Implements a custom User model with UUID primary key, unique email, and identity field (teacher/admin/student)
  • Adds JWT-based authentication with registration, login, profile retrieval, and token refresh endpoints
  • Includes comprehensive API documentation for frontend developers

Reviewed Changes

Copilot reviewed 12 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
user/models.py Defines custom User and UserProfile models with UUID primary key and identity fields
user/views.py Implements API views for user registration and profile retrieval
user/serializers.py Creates serializers for registration and user profile data handling
user/urls.py Configures URL patterns for authentication endpoints
user/signals.py Implements signal to auto-create user profiles
user/admin.py Customizes Django admin interface for User and UserProfile management
back_end/settings.py Configures JWT authentication and custom user model
back_end/urls.py Includes user authentication URLs and media file serving
docs/frontend.MD Provides comprehensive API documentation for frontend developers
README.md Updates documentation links for backend and frontend developers

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

urlpatterns = [
path('signup/', RegisterView.as_view(), name='register'),
path('session/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('refresh/', TokenRefreshView.as_view(), name='token_refresh'),
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The refresh endpoint URL is inconsistent with the documentation. The URL pattern uses 'refresh/' but the documentation references '/auth/refresh' (without trailing slash). Consider adding a trailing slash for consistency.

Suggested change
path('refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path('auth/refresh/', TokenRefreshView.as_view(), name='token_refresh'),

Copilot uses AI. Check for mistakes.
RokuSennyou and others added 2 commits October 4, 2025 00:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@RokuSennyou RokuSennyou merged commit 918e544 into dev Oct 3, 2025
@RokuSennyou RokuSennyou deleted the feat/add-user branch October 3, 2025 16:24
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.

2 participants