Skip to content

Enhancement/Security: Restrict Teacher Registration with Secret Code #23#57

Merged
Eswaramuthu merged 1 commit into
Eswaramuthu:mainfrom
VishalRaut2106:feature/restrict-teacher-registration-23
Feb 7, 2026
Merged

Enhancement/Security: Restrict Teacher Registration with Secret Code #23#57
Eswaramuthu merged 1 commit into
Eswaramuthu:mainfrom
VishalRaut2106:feature/restrict-teacher-registration-23

Conversation

@VishalRaut2106

Copy link
Copy Markdown
Contributor

This PR implements a security restriction for the teacher registration flow as requested in issue #23. It introduces a mandatory "Teacher Code" verification step to prevent unauthorised users from registering as teachers.

Changes Implemented

  • Backend (app.py): Added logic to
    teacher_new
    route to validate the submitted teacher_code. It checks against an environment variable TEACHER_REGISTRATION_CODE (defaults to admin123 if not set).
  • Frontend (templates/teacher_new_2.html): Added a password input field for "Teacher Code" and logic to display validation error messages.

Verification

  • I verified these changes with both manual testing and a regression script:

  • New Feature: Attempting to register with an invalid code correctly denies access and shows an error.
    New Feature: Registering with the correct code (admin123) proceeds successfully.
    Regression: Student registration and login flows remain unaffected.
    Related Issue

image

Closes #23

@vercel

vercel Bot commented Feb 6, 2026

Copy link
Copy Markdown

@VishalRaut2106 is attempting to deploy a commit to the 007's projects Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread app.py

# Check for Teacher Code
teacher_code = request.form.get("teacher_code")
# Get the secret code from environment variable or use default

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.

Correctness: The hardcoded default 'admin123' for TEACHER_REGISTRATION_CODE is a security vulnerability. Remove the default and modify the logic to prevent registration if the environment variable is not configured.

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

File: app.py. At the teacher registration handler where `required_code` is set (around line 392), remove the hardcoded fallback value. Require `TEACHER_REGISTRATION_CODE` to be present and return an error if it is missing. Update the code block to fail closed when the env var is not configured, then compare `teacher_code` against it as before.

@Eswaramuthu Eswaramuthu merged commit f61b902 into Eswaramuthu:main Feb 7, 2026
1 check failed
@VishalRaut2106

Copy link
Copy Markdown
Contributor Author

hey @Eswaramuthu i dont got any point for this successfull PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Easy OSCG26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement/Security] Unrestricted Teacher Registration

2 participants