updates of G2 pair 1#79
Open
Gowwwthami wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates parts of the Django REST API around role retrieval/updating and email/password helper behavior, mainly focusing on query efficiency and safer defaults.
Changes:
- Optimize designation ID retrieval using
values_listand remove a debugprint. - Make
send_emaildefault arguments safer and guardmail_to_useragainst empty inputs. - Minor query cleanup in
add_student_info(.filter(...)instead of.all().filter(...)).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Backend/backend/api/views.py | Role lookup optimized; debug output removed; exception handling updated in password reset flow. |
| Backend/backend/api/helpers.py | send_email signature updated; mail_to_user guarded for empty input; minor queryset cleanup. |
Comments suppressed due to low confidence (1)
Backend/backend/api/helpers.py:131
mail_to_usercurrently sends the same hard-coded password ("user@123") to every created user. This is a credential-reuse risk and makes account takeover easier if any password leaks. Suggestion: generate a unique initial password per user (reusing the existing password-generation helpers) and ensure the stored hashed password matches what is emailed.
max_threads = min(10, len(created_users))
with concurrent.futures.ThreadPoolExecutor(max_workers=max_threads) as executor:
future_to_user = [
executor.submit(mail_to_user_single, user, "user@123") for user in created_users
]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
198
to
201
| except Exception as e: | ||
| print(e) | ||
| finally: | ||
| return Response({"password": new_password,"message": "Password reset successfully."}, status=status.HTTP_200_OK) |
Comment on lines
188
to
192
| batch = int(row[7]) if row[7] else datetime.now().year | ||
| batch_id = Batch.objects.all().filter(name = row[8], discipline__acronym = extrainfo.department.name, year = batch) | ||
| batch_id = Batch.objects.filter(name = row[8], discipline__acronym = extrainfo.department.name, year = batch) | ||
| data = { | ||
| 'id' : extrainfo.id, | ||
| 'programme' : row[8] if row[8] else 'B.Tech', |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ing, fix EMAIL_TEST_MODE type
…xt password storage in reset, fix mail handler crash on ORM input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.